Forum Moderators: coopster
I'm looking for a way to sort my information once a user clicks on the column header. I've searched this topic and found something that was similar, but not quite what I'm looking to accomplish. I would just like a simple way for users to view the information. Like what is used on many sites including eBay, where if a user clicks on different columns they can sort by those columns. Once or twice depending on if they wanted the information in acsending or descending order.
Does this require the use of Javascript, or can this all be handled in php?
Works like a charm. However there is one other issue that now arises. Is there a way to make it order by ascending or descending order using this method. For instance, the first time they click on a column header it would sort it in ascending order, and then if they click on that very same column header it would then switch to descending?
Thanks again,
HTH
somepage.php?sort__columname=asc&sort__columnname2=desc
<?
foreach ($_POST as $key=>$val) {
$tmp = explode("__", $key);
if ($tmp[0]=='sort') $col[] = array($tmp[1], $val);
}
?>
which would leave you an array of multiple columns to sort by and the direction of sort of each