At the moment I am sorting a table list using a hyperlink in the TH of the table that passes the page to return to after the sort routine and the column name. the php sets cookies to perform the ordering of the table.
This is the set-up in the page with the table.
Code: Select all
$page = "multiTrust"; // the filename of this page without the php extension
$column = "zonerp_cs"; // our default sort column
$order = "ASC"; // The default sort order
########################
// Check if we have selected a different column to sort the table by
if (isset($_COOKIE['column'])){
$column = $_COOKIE['column']; // Our chosen sort column (if set).
}
// Check if we have selected a different sort order for our chosen column
if (isset($_COOKIE['direction'])){
$order = $_COOKIE['direction']; // Our chosen direction to order a column (if set)
}
Code: Select all
// Sort by column and order ASC/DESC
$orderby = $_GET['column'];
$page = $_GET['page'];
setcookie ('column', $orderby);
// set order by
if($_COOKIE['direction'] != 'ASC'){
setcookie ('direction', 'ASC');
}
else {
setcookie ('direction', 'DESC');
}
// Reload page
header ("Location: ".$page.".php");
Code: Select all
<th><a href="sortOrder.php?column=name&page=<?php echo $page;?>">Name</a>
I would be grateful for any advice.
TIA
Dave