Noob needs help with displaying data from mySQL database
Noob needs help with displaying data from mySQL database
I am pretty experienced with html php css but I am new at Javascript and jquery and have just come across this very useful library.
I have a web application that I am currently building that this library would be really useful for.
I have read through the examples and run them but I can't get dataTables to work with my app. The data in the div on my page is loaded by as simple piece of javascript called by get() after clicking a load data button and the div is then constructed by a php page that pulls the data from the database. This is currently running on localhost so I can't post a link.
Does anyone have a working example like I am describing above that I can have a look at or suggestions as to how I might make this work.
TIA
Colin
I have a web application that I am currently building that this library would be really useful for.
I have read through the examples and run them but I can't get dataTables to work with my app. The data in the div on my page is loaded by as simple piece of javascript called by get() after clicking a load data button and the div is then constructed by a php page that pulls the data from the database. This is currently running on localhost so I can't post a link.
Does anyone have a working example like I am describing above that I can have a look at or suggestions as to how I might make this work.
TIA
Colin
This discussion has been closed.
Replies
The url is http://collab.turnspain.com/assign_source.php hopefully now someone can give me some help to get it functioning.
Thanks
Colin
Please see thru' this link http://www.datatables.net/usage/
for how the table need to be structured (Dynamic / Static doesn't matter)
If this is how you have structured then it should work without any issues.
And when inspecting using Chrome'es dev tools, found that you haven't coded between and this is precisely your issue
I also noticed your table's is inside instead of . Any specific reason for this style of coding??
v 1.9.4 - Line 6376 - this is where the message is getting popped up - sanity check function within DT script (unless you are using minified ver)
Hope this helps.
[code]
echo "";
// printing table headers
for($i=0; $i<11; $i++)
{
$field = mysql_fetch_field($result);
echo "{$field->name}";
}
echo "";
// printing table rows
$data_row =array();
while($row = mysql_fetch_assoc($result))
{
echo "". $row['id']."";
echo "". $row['first']."";
echo "". $row['middle']."";
echo "". $row['surname']."";
echo "". $row['sex']."";
echo "". $row['b_year']."";
echo "". $row['b_month']."";
echo "". $row['b_day']."";
echo "". $row['b_town']."";
echo "". $row['b_county']."";
echo "". $row['b_country']."";
//echo "Link Records";
echo '';
echo "\n";
}
echo '';
[/code]
This is exactly what is in the page.
I am using the minified version of dataTables.
Colin
See the snapshot in the link below
https://docs.google.com/open?id=0B3byz7-Mzop5V3Z3QzdTZ3lRT0k
[quote]
[code]
echo "";
// printing table headers
for($i=0; $i<11; $i++)
{
$field = mysql_fetch_field($result);
echo "{$field->name}";
}
echo ""; [/code] =>> reverse the closing tags of thead and tr. Its the other way
[/quote]
I have just checked with Firefox and Firebug and the code is shown exactly as it is above not as in your Chrome screen grab. It looks like there might be a bug in Chrome inspect elements. I have just checked it in my version of Chrome (Version 22.0.1229.79 m) and it is correct as per my code not what you are seeing.
Thanks very much for your input so far.
Colin
Your table id is "tbl". Hence it should be
[code]
$("#tbl").dataTable();
[/code]
I see it as initialized with mast_container id in your jfunc.js!! => got it from firebug script tab:)
I see you are loading data using html() to the div mast_container.
While using datatables its ideal to load the data to the with fnCallBack function after successful ajax call. There is also a serverside script available in the example provided.
You can modify as per your needs and use it.
I do not see the use of data tables in your example implementation atleast.
Correct me if I am wrong.
I am afraid that I don't understand what you mean by
[quote]girishmr said: While using datatables its ideal to load the data to the with fnCallBack function after successful ajax call.[/quote]
or
[quote]girishmr said: I do not see the use of data tables in your example implementation atleast.[/quote]
As I said I am very new at Javascript and still trying to get my head around it.
[quote]girishmr said: There is also a serverside script available in the example provided.
You can modify as per your needs and use it.[/quote]
I saw this but was having problems implementing it with what I want to do pulling data from 2 separate tables and was hoping that what I had already working could work with dataTables. I will have another go at converting that script to work the way I want.
Thanks very much
Colin