Let me preface this reply by saying that arrays in PHP are just amazing. IMHO, this is one of the most impressive features of PHP. In PHP an array can also be simultaneously an associative array (aka dictionary, map in other languages). In a plain old C style array each element is identified by its index number. In an associative array, you can assign a key/value pairs to each element. Thus you can idenfify an element by its index or by its key.
So, to solve your problem, I create an array of key/value pairs where the key is the game name and the value is the url. Then I can use ksort() to sort the array by its keys. Note, this assumes that no two games have the same name as each key must be unique.
PHP Code:
while ($row = mysql_fetch_array($result)) {
// for convenience I use the function extract() to place
// each element (result set field) contained in $row
// into its own variable; ie, $game, $url
extract($row);
// Now insert into the array $games the key/value pair $game/$url
$games["$game"] = $url;
}
// now sort the array by its keys
ksort($games);
Run that up a flagpole and see if anyone salutes.
Bookmarks