I've just tried the sub-select approach. Works great on the first page -
shows names listed alphabetically sorted by country. However, once I click
'Next 20' both sorts go bye-bye (neither by name nor country).

I am late to the thread but I wanted to offer another suggestion. Retrieve
the data results into an array and sort the array. I like Peter's idea
though, using a case statement for the appropriate sort order information.
You could also set a variable ($lastSortOrder) to 'default', 'country',
'city', 'whatever' and place this variable within the query. Pseudocode

$lastSortOrder = "default"

$query = "SELECT name, address, city, state, zip FROM table ";
$query .= "ORDER BY " . $lastSortOrder . ";

<input type="submit" name="action" value="Sort By Country"><br>
<input type="submit" name="action" value="Sort By City"><br>

        case "Sort By Country":
        $lastSortOrder = "country"
        case "Sort By City":
        $lastSortOrder = "city"

I know this isn't complete but I HTH!


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to