Order DB through url toggle
| From: | Paul Ihrig | Date: | Fri, 08 Nov 2002 15:04:45 +0000 |
| Subject: | Order DB through url toggle | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23140@lists.php.net to get a copy of this message | ||
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);