Column Sort Question
| From: | Jerry | Date: | Tue, 15 Apr 2003 18:03:13 +0000 |
| Subject: | Column Sort Question | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27107@lists.php.net to get a copy of this message | ||
Hi All,
I am a newbie at this stuff so I hope this makes sense. I want clickable
column headings in a table that sort on click. I got it working using the
code below but can't figure out how to get past the issue of the refresh
button. I only want it sort when a column is clicked. Ever time Refresh is
hit it toggles my sort routine. I understand why it's doing it in my code
but I can't figure out how to code around the Refresh.
Thank,
Jerry
$default_sort_order = 'asc';
$default_order_by = "Application";
$order_by = $_GET['order_by'];
if (empty($order_by))
{
$order_by = $default_order_by;
}
$sort_order=$_SESSION['sort_order'];
if (empty ($sort_order))
{
$sort_order = $default_sort_order;
$_SESSION['sort_order'] = $sort_order;
}else{
if (($_SESSION['sort_order'] == 'asc') &&
($_SESSION['last_infield'] ==
$order_by))
{
$sort_order = 'desc';
$_SESSION['sort_order'] = 'desc';
}else{
$sort_order = 'asc';
$_SESSION['sort_order'] = 'asc';
}
}
$_SESSION['last_infield'] = $order_by;