Im making a site, and I want it to sort the results when you click what you want it to sort by... Im relatively new to PHP (1 or 2 days) so i cant really say what im doing wrong or right... So here is the code i currently have. Corrections, or even ideas for a better way to do this would be appreciated. Also of note, I intend to have a paging (next prev) type of thing later.
global $sorttype, $sortval;
$sorttype = 'Brand';
$sortval ='DESC';
$sortval = urldecode($sortval);
$sorttype = urldecode($sorttype);
$query = "SELECT FROM Amalgamators ORDER BY Amalgamators.$sorttype $sortval";
//$result = mysql_query("SELECT FROM Amalgamators ORDER BY Amalgamators.$sorttype $sortval",$dbh);
$result = mysql_query($query);
echo "<p>$sorttype</p><p>$sortval</p>\n";
echo "<table border=1>\n";
echo "<td>Brand</td> <td>Name</td> <td><a href=$PHP_SELF?sorttype=Price&&sortval=DESC>Price</a></td> <td>Picture</td> </tr>\n";
while ($myrow = mysql_fetch_row($result)) {
{{{Tables stuff here}}}