RE: [PHP-DB] Order DB through url toggle
Thanks Guys.. This seemed to do the trick /* and the desc asc */ $dir = ((isset ($_GET['dir'])) ? (int) $_GET['dir'] : 1); if (!$dir) $dir = ($dir ? 0 : 1); if ($HTTP_GET_VARS['dir'] == 0) { $diri = 'DESC'; } if ($HTTP_GET_VARS['dir'] == 1) { $diri = 'ASC'; } mysql_select_db($database_myFirstSql, $myFirstSql); $query_rsAll = "SELECT * FROM userinfo ORDER BY $orderBy $diri"; -paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Order DB through url toggle
I think you might be missing a = sign in your if statement. Marco - php|architect -- The Monthly Magazine For PHP Professionals Come visit us on the web at http://www.phparch.com! On Fri, 2002-11-08 at 11:26, Paul Ihrig wrote: > 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); > > ?> > > > Last > Name > Phone > Email > Street > City > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Order DB through url toggle
On Saturday 09 November 2002 00:26, Paul Ihrig wrote: > 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 { Try: if $HTTP_GET_VARS['dir'] == 0 { -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Thank God a million billion times you live in Texas. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Order DB through url toggle
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 Last Name Phone Email Street City -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Order DB through url toggle
Let's see: Last Name This is the general idea. $dir will toggle between 1 and 0. There are more "compact" ways of writing this--but this one should be clearer. Marco - php|architect -- The Monthly Magazine For PHP Professionals Come visit us on the web at http://www.phparch.com! On Fri, 2002-11-08 at 10:04, Paul Ihrig wrote: > 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. > > Last Name > > 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 > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php