sandy1028 Posted August 6, 2007 Share Posted August 6, 2007 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/ Share on other sites More sharing options...
tibberous Posted August 6, 2007 Share Posted August 6, 2007 Not quite sure what your trying to do. You want to sort it based the value of name, which will be asc or desc? Post the phonedb.txt and I'll take a look at it for you. Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/#findComment-316421 Share on other sites More sharing options...
sandy1028 Posted August 6, 2007 Author Share Posted August 6, 2007 sokodoku : halli : 32 : sudoku@ac.in : 77451278655 : 513486 abc : xyz : 23 : abc@abc.in : 98453540 : 567335 ytt : dfi : 32 : sdfdu@ac.in : 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 Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/#findComment-316440 Share on other sites More sharing options...
sandy1028 Posted August 6, 2007 Author Share Posted August 6, 2007 hi, I have attached to the text file.... Help me how to sort it only when clicked on header. Should I use javascript? Please help me with this Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/#findComment-316463 Share on other sites More sharing options...
sandy1028 Posted August 6, 2007 Author Share Posted August 6, 2007 Hi, Help me with this problem. I am facing it too problematic Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/#findComment-316511 Share on other sites More sharing options...
sandy1028 Posted August 6, 2007 Author Share Posted August 6, 2007 Hi, When I click on the header of the column..... the mouse pointer points to the top of the page. How do I point at the particular header position when clicked Quote Link to comment https://forums.phpfreaks.com/topic/63482-query/#findComment-316542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.