Jump to content

Dynamic sorting problem


thunderbird22

Recommended Posts

Hi guys,

 

I have no idea if this is under AJAX thread, therefore if the moderators can help me, just move it to the correct area.

 

Here is my problem.

Using PHP and MySQL I retrieve information from a database and I put them in an html table. After the table is presented, I want the column headers to be clickable and when I click them I want the table to be dynamically ordered by that column.

 

my code goes like this:

if (mysql_num_rows($result) > 0)
{
echo '<table border=1 cellpadding=10>';
echo '<tr><td>ID</td><td>USER</td><td>DEPARTMENT</td><td>AGE</td></tr>';

while ($row = mysql_fetch_object($result))
{
echo '<tr>';
echo '<td>' . $row->id;
echo '</td>';
echo '<td>' . $row->user;
echo '</td>';
echo '<td>' . $row->department;
echo '</td>';
echo '<td>' . $row->age;
echo '</td>';
echo '</tr>';

}
echo '</table>'
}

 

 

 

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.