RE: [PHP-DB] Order DB through url toggle
| From: | Paul Ihrig | Date: | Fri, 08 Nov 2002 16:26:38 +0000 |
| Subject: | RE: [PHP-DB] Order DB through url toggle | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23147@lists.php.net to get a copy of this message | ||
well i tried that..
but it out puts the right number.
but it is not taking that var to switch ACS or DESC...
http://localhost/php/default2.php?orderBy=priLastName&dir=0
http://localhost/php/default2.php?orderBy=priLastName&dir=1
/* here we set up out order by clause */
$orderBy = 'priLastName';
if (isset($HTTP_GET_VARS['orderBy'])) {
$orderBy = $HTTP_GET_VARS['orderBy'];
}
/* and the desc asc */
if $HTTP_GET_VARS['dir'] = 0 {
$diri = 'DESC';
} else {
$diri = 'ASC';
}
mysql_select_db($database_myFirstSql, $myFirstSql);
$query_rsAll = "SELECT * FROM userinfo ORDER BY $orderBy $diri";
$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);
Then
<?
$dir = ((isset ($_GET['dir'])) ? (int) $_GET['dir'] : 1);
if (!$dir)
$direction = 'desc';
$dir = ($dir ? 0 : 1);
?>
<td><a href="default2.php?orderBy=priLastName&dir=<?= $dir?>">Last
Name</a></td>
<td><a href="default2.php?orderBy=priPhone">Phone</a></td>
<td><a href="default2.php?orderBy=priEmail">Email</a></td>
<td><a href="default2.php?orderBy=priStreet">Street</a></td>
<td><a href="default2.php?orderBy=priCity">City</a></td>