I want to sort the database search results in php. Basically, the results are returned on a php page and need to be sorted either by columns. I managed to display the results on the page witht he code below and it works, but now i need to add the sorting bit, but i am stuck with it. I dont want to fetch the data from the database again but just to manipulate the existing entries. how can this be achieved in php?
$sql .= 'SELECT * FROM dealstable WHERE search like "%' . $dest . '%" ';
$result = mysql_query($sql) or die("Query error: ".mysql_errno().": ".mysql_error());
while ($row = mysql_fetch_array($result))
print "<td><img height='60' src='" . $row["id"] . "'></td>"
print "<td align='center'>" . $row["deals"] . "</td>"
I want to add the sort option on the search results so that users can filter
<select name="sort" " id="sort" style="width:150px;">
<option value="lowprice">Lowest Price Asc</option>
<option value="highprice">Highest Price Desc</option>
Thanks in advance