Hi all. I have a table whereby the table columns are sorted according to what table column is clicked. If I click it a second time it will sort those contents in the opposite direction (the usual stuff).
So, I have that bit sorted, and have an image declared according to what direction the content is being sorted at. But the problem is that all the table column contain this image. How can I ensure that only the table column selected to sort contains the arrow pointing up or down (depending on the ACS or DESC function).
Here is my source that does the above but has the image on all table column headers where the img src is called.
So, I have that bit sorted, and have an image declared according to what direction the content is being sorted at. But the problem is that all the table column contain this image. How can I ensure that only the table column selected to sort contains the arrow pointing up or down (depending on the ACS or DESC function).
Here is my source that does the above but has the image on all table column headers where the img src is called.
Code:
$orderby = $_GET['o'];
$dir=$_GET['d'];
if(!isset($orderby)){
$orderby = "SalesID";
}
if(!isset($dir)){
$dir = "ASC";
}
if(strcmp($dir,"ASC")!=0 and strcmp($dir,"DESC")!=0){
$dir = "DESC";
}
if($orderby == NULL)
{
$order="SalesID";
}
$query = "SELECT * FROM leads ORDER BY $orderby $dir";
$result=mysql_query ($query) or die ("Oh oh"); //(mysql_error());
if(strcmp($dir,"ASC")==0){
$ddir = "DESC";
$src="down";
}else{
$ddir = "ASC";
$src="up";
}
$colourcount=1;
.....
echo "<table class='ex' cellpadding='4' cellspacing='0'>\n";
echo "<tr><td class='header' align='center' ?> onClick="MyWindow=window.open('reglist.php?o=SalesID&d=<?=$ddir?>','_parent');"><? echo "ID <img src='images/$src.gif'></td>
<td class='header' ?>onClick="MyWindow=window.open('reglist.php?o=CustAddress&d=<?=$ddir?>','_parent');"><? echo "Customer Name <img src='images/$src.gif'></td>
<td class='header' ?> onClick="MyWindow=window.open('reglist.php?o=CustAddress&d=<?=$ddir?>','_parent');"><? echo "Address <img src='images/$src.gif'></td>
<td class='header' ?> onClick="MyWindow=window.open('reglist.php?o=CustTel&d=<?=$ddir?>','_parent');"><? echo "Contact No <img src='images/$src.gif'></td>
<td class='header' ?> onClick="MyWindow=window.open('reglist.php?o=CustStatus&d=<?=$ddir?>','_parent');"><? echo "Status <img src='images/$src.gif'></td>
<td class='header' ?> onClick="MyWindow=window.open('reglist.php?o=CustDescription&d=<?=$ddir?>','_parent');"><? echo "Description <img src='images/$src.gif'></td>
<td class='header' ?> onClick="MyWindow=window.open('reglist.php?o=AgentAssigned&d=<?=$ddir?>','_parent');"><? echo "Agent <img src='images/$src.gif'></td></tr>\n";