Jump to content

query


sandy1028

Recommended Posts

Hi,

 

How can I pass the query string when clicked on header the sort order should change.

Should I use javascript for this.

When I clcik on the address I sort of Name changes.

I am sorting the header independently.

Please help me with this

 

$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/63482-query/
Share on other sites

sokodoku : halli : 32 : [email protected] : 77451278655 :  513486
abc : xyz : 23 : [email protected] : 98453540 :  567335
ytt : dfi : 32 : [email protected] : 33454578455 :  513486

 

I just want to sort independently of the columns.

I dont want to use multi sort.

When I click on header only then sort should change.

Now in the code the sort order changes when I click on Address which should not happen

Link to comment
https://forums.phpfreaks.com/topic/63482-query/#findComment-316440
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.