Current location: Hot Scripts Forums » Programming Languages » PHP » need to add up or down arrow in the headerlist in php


need to add up or down arrow in the headerlist in php

Reply
  #1 (permalink)  
Old 03-26-04, 01:17 AM
rani rani is offline
Newbie Coder
 
Join Date: Jan 2004
Location: b'lore
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
need to add up or down arrow in the headerlist in php

hi ALL,

i have list of 3 things listed in the brower.
the output looks like this
------+-----+-----+
|field 1 | field2 | field3 | header
+------+-----+-----+

if i click in any of the header
eg. feild 1 the the list arraged in asc order,if click once again then it arragesin descending order..
now i want to add an arrow in the header depending on
what order it arranged.
can anyone help me out .
i have written the code in php..
thanks
rani
Reply With Quote
  #2 (permalink)  
Old 03-26-04, 02:11 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
the link (URL) of each of these should contain something like order=desc or asc ..
e.g. field 1 link gotta be something like this:
Code:
<a href="field1.php?order=DESC">Field 1</a>
now have something in your php code that will look for the order wanted..
as for the arrow issue, just see if order is ASC for example then the image is arrowasc.gif or what ever .. and example will help..
PHP Code:

if (isset($_GET['order'])) {

  
$order $_GET['order'];

  if (
$order == 'DESC') {
    
$image 'arrowup.jpg';

//DO DESC THE SORTING HERE ..

  
} elseif ($order == 'ASC') {
    
$image 'arrowdown.jpg';

//DO ASC SORTING HERE

  
}
}

//this is how to output the image .
echo '<img src="images/'.$image.'" />'
hope that helps
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 03-31-04, 01:00 AM
rani rani is offline
Newbie Coder
 
Join Date: Jan 2004
Location: b'lore
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
yes i could do till here,but i have one problem..
when the page is intially loaded,

[ i am also passing the header name (field name eg field1 be name)
if field name is not passed then to mysql query default fieldname will be name with the intial conditon to sort as asc.
feildname=name sort =asc
eg: select * from tablename oderby fieldname sort;]
when the page loads the arrow shd not come in any header. fine till here i could do,but i have limited the number of rows to be 40, if it is more then it goes to second page..
here it the prb,when it goes to 2nd page the arrow shows up in name field wh i don't want..
otherwise i managed to show only to header wh user click..but the intial conditon with 2nd page is the problem can someone help here.



Quote:
Originally Posted by NeverMind
the link (URL) of each of these should contain something like order=desc or asc ..
e.g. field 1 link gotta be something like this:
Code:
<a href="field1.php?order=DESC">Field 1</a>
now have something in your php code that will look for the order wanted..
as for the arrow issue, just see if order is ASC for example then the image is arrowasc.gif or what ever .. and example will help..
PHP Code:

if (isset($_GET['order'])) {

  
$order $_GET['order'];

  if (
$order == 'DESC') {
    
$image 'arrowup.jpg';

//DO DESC THE SORTING HERE ..

  
} elseif ($order == 'ASC') {
    
$image 'arrowdown.jpg';

//DO ASC SORTING HERE

  
}
}

//this is how to output the image .
echo '<img src="images/'.$image.'" />'
hope that helps
Reply With Quote
  #4 (permalink)  
Old 03-31-04, 05:32 AM
rani rani is offline
Newbie Coder
 
Join Date: Jan 2004
Location: b'lore
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
yes i could do till here,but i have one problem..
when the page is intially loaded,
the up or down arrow was displayed,which i figured out.
thanks



Quote:
Originally Posted by NeverMind
the link (URL) of each of these should contain something like order=desc or asc ..
e.g. field 1 link gotta be something like this:
Code:
<a href="field1.php?order=DESC">Field 1</a>
now have something in your php code that will look for the order wanted..
as for the arrow issue, just see if order is ASC for example then the image is arrowasc.gif or what ever .. and example will help..
PHP Code:

if (isset($_GET['order'])) {

  
$order $_GET['order'];

  if (
$order == 'DESC') {
    
$image 'arrowup.jpg';

//DO DESC THE SORTING HERE ..

  
} elseif ($order == 'ASC') {
    
$image 'arrowdown.jpg';

//DO ASC SORTING HERE

  
}
}

//this is how to output the image .
echo '<img src="images/'.$image.'" />'
hope that helps
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 12:31 AM
Realtime PHP Code Obfuscation barrywien General Advertisements 1 11-16-03 06:50 PM
How to convert php generated pages to SE friendly HTML or PHP(SE friendly) -CLASS 101 crippled PHP 1 11-16-03 06:37 AM


All times are GMT -5. The time now is 10:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.