Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    zc1
    zc1 is offline
    New Coder
    Join Date
    Jun 2007
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    [solved]Column sorting

    Hi,

    I have found the below code to sort columns, but would like to hide it if another column is sorted as I have the following columns: username , age , online etc... so if online is sorted there is no text saying Sort ascending or Sory descending in username or age.

    This is by current code for online
    Code:
    if ($sortorder == 'asc') {
    $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>") ; // default replaced by single link
    } else {
    $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=desc\" title=\"Sort the records in descending order\">Sort descending</a>") ; 
    }
    If have tried adding: && $orderby == 'online' to the if line but that doesn't work just breaks the above code.

    In the script I am trying to edit has case code would I be able to put it into that ?
    case code below

    Code:
    case 'age' :
    	$orderby = ' age ';
    	break;
    case 'username':
    	$orderby = ' username ';
    	break;
    case 'online':
    	$orderby = ' lastvisit ';
    	break;
    Can anyone help ?

    Regards,
    Garry
    Last edited by zc1; 06-05-2007 at 03:13 PM.

  • #2
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    if ($orderby == 'online')
    if ($sortorder == 'asc') {
    $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>") ; // default replaced by single link
    } else {
    $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=desc\" title=\"Sort the records in descending order\">Sort descending</a>") ; 
    }
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #3
    zc1
    zc1 is offline
    New Coder
    Join Date
    Jun 2007
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks for your reply.

    That bit of code did not work, but I did get it work work by putting it in the case code for example

    Code:
    		case 'online':
    			$orderby = ' lastvisit ';
                if ($sortorder == 'asc') {
                $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=asc\" title=\"Sort the records in ascending order\">Sort ascending</a>") ; // default replaced by single link
                } else {
                $orderlink = ("<a href=\"newmemberslist.php?orderby=online&sortorder=desc\" title=\"Sort the records in descending order\">Sort descending</a>") ; 
                }			
    			break;
    Regards,
    Garry


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •