Jump to content

Recommended Posts

Hi,

 

I have a code which which sorts the tree column independently.

When  I click on the another column header the tree is not in ascending order.

How to pass the query string when clicked only on column header the sort order should change.

Now when clicked on another column also the sort order is changed

 

 

 

$lines = file('./phonedb.txt');

$name = $_GET['name'];
$lines = file('phonedb.txt');
if($name != "asc")
{
echo "<ul><li class=\"connection\"><a href=\"tree.php?name=asc\">Name</a>";
}
if($name == "asc"){
echo "<ul><li class=\"connection\"><a href=\"tree.php?name=desc\">Name</a>";
}

echo "<ul>";

if($name == "asc")
{
$line1 = array();
$line2 = array();
$line3 = array();
$line4 = array();
$line5 = array();
$line6 = array();
foreach($lines as $line)
{
$text_line=explode(":",$line);
$line1[] = $text_line[0];
$line2[]=$text_line[1];
$line3[]=$text_line[2];
$line4[]=$text_line[3];
$line5[]=$text_line[4];
$line6[]=$text_line[5];
}
sort($line1);
for($i=0;$i<=count($line1);$i++){
$tool=$line1[$i].$line2[$i].$line3[$i].$line4[$i].$line5[$i].$line6[$i];
echo "<li class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover'\" onMouseOut=\"javascript:this.className='ToolText'\">--$line1[$i]<span>$tool</span></li>";
}
}
if($name != "asc")
{
foreach($lines as $line)
{
        $text_line=explode(":",$line);
$tool=$text_line[0].$text_line[1].$text_line[2].$text_line[3].$text_line[4].$text_line[5];
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 "<li class=\"connection\"><a href=\"tree.php?address=asc\">Address</a>";
}
if($address == "asc"){
echo "<li class=\"connection\"><a href=\"tree.php?address=desc\">Address</a>";
}



echo "<ul>";

if($address == "asc")
{
$line1 = array();
$line2 = array();
$line3 = array();
$line4 = array();
$line5 = array();
$line6 = array();
foreach($lines as $line)
{
$text_line=explode(":",$line);
$line1[] = $text_line[0];
$line2[]=$text_line[1];
$line3[]=$text_line[2];
$line4[]=$text_line[3];
$line5[]=$text_line[4];
$line6[]=$text_line[5];
}
sort($line2);
for($i=0;$i<=count($line2);$i++){
$tool=$line1[$i].$line2[$i].$line3[$i].$line4[$i].$line5[$i].$line6[$i];
echo "<li class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover'\" onMouseOut=\"javascript:this.className='ToolText'\">--$line2[$i]<span>$tool</span></li>";
}
}

if($address != "asc")
{
foreach($lines as $line)
{
        $text_line=explode(":",$line);
$tool=$text_line[0].$text_line[1].$text_line[2].$text_line[3].$text_line[4].$text_line[5];
echo "<li class=\"ToolText\" onMouseOver=\"javascript:this.className='ToolTextHover'\" onMouseOut=\"javascript:this.className='ToolText'\">--$text_line[1]<span>$tool</span></li>";

}
}

echo "</ul></li>";


Link to comment
https://forums.phpfreaks.com/topic/63149-passing-the-query-string/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.