Order DB through url toggle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All!
i am new to the list & to PHP..


So i have a recordset that displays my contacts in a table.
the headers of the columns look like this.

<td><a href="default2.php?orderBy=priLastName">Last Name</a></td>

so when a user clicks on it
It will Re-Sort the rs by priLastName Asc.

what i want to do is make it a toggle
between table name ASC or DESC..

any ideas?
thanks.

-paul

#$orderBy = 'priFirstName';

$orderBy = 'priLastName';
if (isset($HTTP_GET_VARS['orderBy'])) {
  $orderBy = $HTTP_GET_VARS['orderBy'];
}
#?orderBy=priFirstName

$maxRows_rsAll = 5;;
$pageNum_rsAll = 0;
if (isset($HTTP_GET_VARS['pageNum_rsAll'])) {
  $pageNum_rsAll = $HTTP_GET_VARS['pageNum_rsAll'];
}
$startRow_rsAll = $pageNum_rsAll * $maxRows_rsAll;

mysql_select_db($database_myFirstSql, $myFirstSql);
$query_rsAll = "SELECT * FROM userinfo ORDER BY $orderBy ASC";
$query_limit_rsAll = sprintf("%s LIMIT %d, %d", $query_rsAll,
$startRow_rsAll, $maxRows_rsAll);
$rsAll = mysql_query($query_limit_rsAll, $myFirstSql) or die(mysql_error());
$row_rsAll = mysql_fetch_assoc($rsAll);


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux