sandy1028 Posted August 3, 2007 Share Posted August 3, 2007 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/63149-passing-the-query-string/ Share on other sites More sharing options...
Daniel0 Posted August 3, 2007 Share Posted August 3, 2007 It should probably be $_GET['name'] and not $name. The same goes for $address. Quote Link to comment https://forums.phpfreaks.com/topic/63149-passing-the-query-string/#findComment-314783 Share on other sites More sharing options...
sandy1028 Posted August 3, 2007 Author Share Posted August 3, 2007 Hi, The sort is independent to other column. For Particular column I need to sort ascending and descending. If I click only on the header of Name the sort should change. Till I click on the header the order should not change for the column. Quote Link to comment https://forums.phpfreaks.com/topic/63149-passing-the-query-string/#findComment-314796 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.