webguync Posted September 22, 2009 Share Posted September 22, 2009 This might be more of a JQuery question, but I have posted there and also did a lot of google searching and haven't come up w/ an answer so thought I would try here. I came across a JQuery table sorting plug-in that works great as long as there is static data, but when I try it on a table pulling in data from MySQL via PHP it doesn't work. Has anyone gotten something similar to work in PHP/MySQL data? Here is an example of the filer. http://ideamill.synaptrixgroup.com/jquery/tablefilter/tabletest.htm Quote Link to comment Share on other sites More sharing options...
jcombs_31 Posted September 22, 2009 Share Posted September 22, 2009 I don't see how it would make a difference. PHP is just going to create the table data for you, which jquery would interpret the same as a table you created manually. You'd have to be more specific with exactly what you are doing to populate your table and how you are using the plugin. Quote Link to comment Share on other sites More sharing options...
webguync Posted September 23, 2009 Author Share Posted September 23, 2009 yes, I would think the same thing, but it works with a regular table and does not with PHP/mySQL. here is code I am using with PHP/MySQL. <html> <head> <title>Filter Test</title> <link rel="stylesheet" type="text/css" href="css/tableFilter.css"> <link rel="stylesheet" type="text/css" href="css/tableFilter.aggregator.css"> <link href="css/report.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text/javascript" src="js/event.js"></script> <script type="text/javascript" src="js/jquery.tablesorter.pack.js"></script> <script src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery-packed.js"></script> <script type="text/JavaScript" src="js/jquery.cookies-packed.js"></script> <script type="text/javascript" src="js/prototypes-packed.js"></script> <script type="text/javascript" src="js/json-packed.js"></script> <script type="text/javascript" src="js/jquery.truemouseout-packed.js"></script> <script type="text/javascript" src="js/daemachTools-packed.js"></script> <script type="text/javascript" src="js/jquery.tableFilter-packed.js"></script> <script type="text/javascript" src="js/jquery.tableFilter.aggregator-packed.js"></script> <script type="text/javascript" src="js/jquery.tableFilter.columnStyle-packed.js"></script> </head> <?php $con = mysql_connect("localhost","username","pw"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DBName", $con); $result = mysql_query("SELECT * FROM roster_TEST"); echo "<body><table border='1'> <thead> <tr> <td><p>Click button to release filter application</p></td> <td colspan='3' align='middle'> <form> <input onClick='$(\"table\").eq(0).tableFilter();' type=\"button\" value=\"Go\"> </form> </td> </tr> <tr> <th>Last Name</th> <th>First Name</th> <th>Employee ID</th> <th>Title</th> <th>Region</th> <th>District</th> <th>Territory</th> </tr></thead>"; while($row = mysql_fetch_array($result)) { echo "<tbody><tr>"; echo "<td>" . $row['last_name'] . "</td>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['employee_id'] . "</td>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['region'] . "</td>"; echo "<td>" . $row['district'] . "</td>"; echo "<td>" . $row['territory'] . "</td>"; echo "</tr>"; } echo "</tbody></table>"; mysql_close($con); ?> </body> </html> and links to where it works with straight html http://etsi-dataservices.com/NNPhase3/TEST/report/index.php and doesn't work with PHP/MySQL http://etsi-dataservices.com/NNPhase3/TEST/report/MySQL_Table.php Quote Link to comment Share on other sites More sharing options...
jcombs_31 Posted September 23, 2009 Share Posted September 23, 2009 My clue of the day will be to look at tbody that you are generating from your loop. Quote Link to comment Share on other sites More sharing options...
webguync Posted September 23, 2009 Author Share Posted September 23, 2009 ah, I see:-) Two TBody's were being created. I placed the TBody before the while loop and appears to work now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.