I have a set of results that I am pulling from a database. If the Get variables of "sortby" and "order" are not set, then I use default values. On the generated page I have different links which specify the "sortby" variable and a function that ATTEMPTS to determine the current "order" and get the reverse of it.
So if I click on the link once it will sort in ASC order and a second time in DESC order. The function works but only on every other link.
I have four links on the page, RFQ#, Customer PN, Company PN and Date. RFQ#, and Company # will work just fine, but Customer PN and Date won't work. I am not getting errors in the log, but it just doesn't seem to be picking up the values.
here is the reverse sort function
function get_opposite_order($input, $order) ## Get opposite order
{
if ($GET["order"] == "ASC"){
$GET["order"]= "DESC";
return $GET["order"];
} else {
$GET["order"]= "ASC";
return $_GET["order"];
}
}
The links all follow the same principal
<a href="<?php echo $hef."&order=".get_opposite_order("Receive_Date", $_GET["order"]);?>">Receive Date</a>
The mysql statement looks like this
$SESSION["search_query"]="select * from tracking_quote where Status != 'COMPLETE' ";
$SESSION["search_query"].= "order by tracking_quote.";
if (!isset($_GET['sortby'])) {
$_SESSION["search_query"].= "date_modified";
$_GET["sortby"]="date_modified";
} else {
$_SESSION["search_query"].= $_GET["sortby"];
}
if (!isset($_GET['order'])) {
$_SESSION["search_query"] .= " DESC";
$_GET['order']= "DESC";
} else {
$_SESSION["search_query"] .= " ". $_GET['order'];
}
Any thoughts or suggestions? The every other issue really has me stumped.