Assume in Page 1 that I have the below code:
if($col==1)
{
$OutCtrl=1;
//echo "<a href=webpurchase1.php>Company Name</a> ";
echo "<a href=\"webpurchase1.php?sort=companyname\">Company Name</a> ";
}
Then in Page 2 I have the following:
if($_GET['sort']==companyname)
{
if($sortCompany==0)
{
$query=" SELECT * FROM webpurchases ORDER BY companyname DESC";
$sortCompany=1;
}
else
{
$query=" SELECT * FROM webpurchases ORDER BY companyname ASC ";
$sortCompany=0;
}
$OutCtrl=0;
}
I want that everytime I click on the Company Name link, the table will sort alternatingly between descending and ascending order. But the above code just seem to be executing the descending order code portion only. I only declared sortCompany in the above segment and nowhere else.
Please help. Thanks.