I've this php script that displays information stored in a MYSQL DB..
it shows the data in a tabular format..
What i'm trying to do is to make php sort the data in the table according to what user specifies (by clicking a link that sends a value using GET)..
$sort = $_GET['sort_by'];
i've this code for the default order of the information:
$query = "SELECT `rego`, `make`, `model`, `color`, `kms`, `year`, `adprice`, `branch`, `state`, `saleprice`, `salesperson` FROM `vehicles` ";
$result = mysql_query($query);
and this one for when a user specifies what way to sort the info:
$order = "SELECT `rego`, `make`, `model`, `color`, `kms`, `year`, `adprice`, `branch`, `state`, `saleprice`, `salesperson` FROM `vehicles` ORDER BY `vehicles`.`$sort` ASC LIMIT
0, 30 ";
$orderresult = mysql_query($order);
i'm using a "while" loop to display all the data from the DB..
while ($row = mysql_fetch_assoc($result)) {
what i'd like to do is to set the while loop to use "$row = mysql_fetch_assoc($result)" for the default order and to use $row = mysql_fetch_assoc($orderresult) when user specfies what way to sort info.