Jump to content

JQuery Table sort and PHP/MySQL


webguync

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.