Sort
Posted: Mon Aug 06, 2007 2:40 am
hi,
I have a problem in sorting. The sort is done for independently for each columns.
Problem is when the sort of Name is in ascending order and when I click on the Address header the sort of the Name column also changes to descending order.
Please help me with this. The sort order should not change unless I click on the particular header.
I have a problem in sorting. The sort is done for independently for each columns.
Problem is when the sort of Name is in ascending order and when I click on the Address header the sort of the Name column also changes to descending order.
Please help me with this. The sort order should not change unless I click on the particular header.
Code: Select all
$name = $_GET['name'];
$address = $_GET['address'];
$lines = file('phonedb.txt');
echo "<ul id=\"containerul\"><li class=\"connection\">View Tree";
if($name != "asc")
{
echo "<ul><li class=\"connection\"><a href=\"tree.php?name=asc\">Name</a>";
}
else if($name == "asc"){
echo "<ul><li class=\"connection\"><a href=\"tree.php?name=desc\">Name</a>";
}
echo "<ul>";
if($name == "asc")
{
$line1 = array();
foreach($lines as $line)
{
$text_line=explode(":",$line);
$line1[] = $text_line[0];
}
sort($line1);
for($i=0;$i<=count($line1);$i++){
$text_line=explode(":",$line);
echo "<li class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover'\" onMouseOut=\"javascript:this.className='ToolText'\">--$text_line[0]<span>$tool</span></li>";
}
}
echo "</ul></li>";
if($address != "asc")
{
echo "<ul><li class=\"connection\"><a href=\"tree.php?address=asc\">Address</a>";
}
else if($address == "asc"){
echo "<ul><li class=\"connection\"><a href=\"tree.php?address=desc\">Address</a>";
}
echo "<ul>";
if($address == "asc")
{
$line2 = array();
foreach($lines as $line)
{
$text_line=explode(":",$line);
$line1[] = $text_line[1];
}
sort($line2);
for($i=0;$i<=count($line2);$i++){
$text_line=explode(":",$line);
echo "<li class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover'\" onMouseOut=\"javascript:this.className='ToolText'\">--$text_line[1]<span>$tool</span></li>";
}
}
echo "</ul></li>";