Sort Columns in tables
Posted: Sat Jun 25, 2005 7:19 pm
Hi Gang,
I'm trying to use the following code to sort columns generated by a mysql query.
It doesn't sort the fields by default as it should or when you click the sort links.
It just reloads the page with no errors.
Any obvious errors in the code that you can see?
tia, Will.
I'm trying to use the following code to sort columns generated by a mysql query.
It doesn't sort the fields by default as it should or when you click the sort links.
It just reloads the page with no errors.
Any obvious errors in the code that you can see?
tia, Will.
Code: Select all
// In Common.inc file
$default_sort_order = 'ASC';
$default_order_by = 'colloPaperName';
// Globals
global $default_sort_order, $default_order_by, $sort_order, $order_by;
// Sort Commands
if(empty($order_by)) {
$order_by_str = "ORDER BY $default_order_by";
$order_by = $default_order_by;
}
else $order_by_str = "ORDER BY $order_by";
if(empty($sort_order)) {
$sort_order_str = $org_sort_order = $default_sort_order;
$sort_order = 'DESC';
}
else {
$sort_order_str = $org_sort_order = $sort_order;
if($sort_order == 'DESC') $sort_order = 'ASC';
else $sort_order = 'DESC';
}
// Table SetUp
echo "<th width=150px valign=top align=left nowrap>
<a href=\"".$_SERVER['PHP_SELF']."\"?action=fnSearchResults&sort_order=\".$sort_order.\"&order_by=paperCategory\"'>
Paper Category</a></th>";