View Full Version : How to order by downloads/title my downloads script?

06-09-2006, 10:57 AM

My question is how do I make "Order by Downloads/Title/Date" for my download script? Help is really appreciated!

My script:

if (mysql_num_rows($result) > 0)
while ($row = mysql_fetch_assoc($result))
echo ('<tr>');
echo ('<td valign="top"><a href="screenshots/'.$row["screenshot"].'.jpg"><img src="screenshots/'.$row["screenshot"].'thumb.jpg" border="0" /></a></td>');
echo ('<td width="100%" valign="top"><div class="title">'.$row["title"].'</div>');
echo ('Author: '.$row["author"].'<br />');
echo ('Description: '.$row["description"].'<br />');
echo ('<br /><br />');
echo ('<a href="download.php?file='.$row["filename"].'.zip" class="menuitem">Download</a> ('.$row["downloads"].' Downloads)');
echo ('</td>');
echo ('</tr>');
echo ('No downloads.');

06-09-2006, 11:28 AM
There are a number of ways to do this.
1 Create a Javascript array of the data and a script to clear and rewrite the table
2 Use links to rerun the page with an order by field in the query. Your page will need to keep track of the rest of the query by
2a saving data in a session
2b resubmitting data in a form (requires Javascript)

1 is probably the best option if you know a bit of Javascript and have a small result set.

06-09-2006, 03:08 PM
I would recommend option 2