Hello there, I'm having some problem thinking of a way to sort my tables by their respective fields when clicked on.
At the moment I have my code set up as so :
echo ' <tr>
<th>ID</th>
<th>Name</th>
<th>Director</th>
<th>Actors</th>
<th>Release Date</th>
<th>Plot</th>
<th><a href="my_test.php?sortby=rating"> Rating</a></th>
</tr>';
This is outside the while loop that prints out the fields from a SELECT * FROM statement :
a) How do I code my program so that when the Rating table header is clicked, the table sorts itself by Rating (Ascendingly or Descendingly) ?
I had this in mind :
if(isset($_GET['sortby']))
{
$sortByThis = $_GET['sortby'];
$querystring = "SELECT * FROM moviedb ORDER BY $sortByThis";
..[I]display fields in a while loop[/I]
The only problem with that was, when the Rating header was clicked, It displayed the sorted Fields at the bottom of the already displayed 'SELECT * FROM moviedb' Table, duplicating the data.
Any ideas/suggestions?