Jump to content

Recommended Posts

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

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

 

case 'age' :
$orderby = ' age ';
break;
case 'username':
$orderby = ' username ';
break;
case 'online':
$orderby = ' lastvisit ';
break;

 

Can anyone help ?

 

Regards,

Garry

 

Link to comment
https://forums.phpfreaks.com/topic/54243-solved-column-sorting/
Share on other sites

Hi,

 

I just tested a bit more and noted if I have the following as the 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;

 

It seems to do what I want

 

Regards,

Garry

Link to comment
https://forums.phpfreaks.com/topic/54243-solved-column-sorting/#findComment-268214
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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