I want to give users of my site the option of re-organinng the order the results are returned.
so far I have...
$default_sort = 'featureSite';
$allowed_order = array ('entryDate', 'companyName','featureSite');
if (!isset ($GET['order']) ||
!in_array ($GET['order'], $allowed_order)) {
$order = $default_sort;
}
else {
$order = $_GET['order'];
}
$db = mysql_connect("localhost","xxxx","xxxxxx");
mysql_select_db ("xxxxxxxxx");
$query = "SELECT directory.featureSite, directory.mainBanner, contact.companyName, directory.incAddress, contact.Address, contact.Town, county.countyName, contact.postcode,
directory.incPhone, contact.phone, directory.incEmail, contact.email, contact.website, directory.smallBanner, directory.description, contact.entryDate
FROM categories, contact, county, directory
WHERE categories.categoryID = directory.categoryID
AND directory.companyID = contact.companyID
AND directory.countyID = county.countyID
AND categories.categoryID LIKE '{$POST['category']}'
AND directory.countyID LIKE'{$POST['county']}'
ORDER BY $order";
$result = mysql_query ($query);
$row = mysql_fetch_assoc ($result);
foreach ($row as $heading=>$column) {
echo "<p align='center'>";
if (in_array ($heading, $allowed_order)) {
echo "<a href=\"{$_SERVER['PHP_SELF']}?order=$heading\">$heading</a>";
}
}
echo "</p>";
Then there's the printing of the results.
However, when I try this clicking the links produces zero results.
Thank you
Dee