Hi All,
I have a script that sorts and displays the contents of a database by the ID.
The first row of the database contains the heading a couple of these I would like to be able to sort the records by asc and desc.
I dont really want to create new pages for each of the recordsets so this is what i want to know if this can be done.
when the page is loaded it sorts from this command
$query_vm = "SELECT * FROM customers ORDER BY id ASC";
Now in the top row i have the heading Last Login << >>
What i want to do is be able to click on the << to order all the records last login ascending and >> descending.
This would be done using the following
if (isset($HTTP_GET_VARS['llasc'])) {
$colname_sort1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['llasc'] : addslashes($HTTP_GET_VARS['llasc']);
}
mysql_select_db($database_smslist, $smslist);
$query_sort1 = sprintf("SELECT * FROM customers WHERE last_login = '%s' ORDER BY last_login ASC", $colname_sort1);
And calling it via a link from the << >>
However, this calls a complete new recordset, which doesnt display the records as required.
Can you use an IF statement in here for the HTTP_GET_VARS so that if the URL = last_login=llasc it would use the current recordset but change the
SELECT * FROM customers ORDER BY id ASC
I hope what im trying to do here is understandable!