06-07-2005, 05:03 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: May 2005
Location: Maine|USA
Posts: 17
Thanks: 0
|
Sort order problem
I have a little game database, I am trying to sort the data (per a user click) by title, or by systme or by whatever the user specifies. Here's the code that I have, it's not sorting:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Games Database</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <link rel="stylesheet" type="text/css" href="http://misc.techiehq.net/stuff/css/games.css" /> </head> <body> <div class="body_fore">
<div class="title"> Games: </div>
<table class="table_head"> <tr> <td width="85">System <a href="index.php?order=system">^</a> v</td> <td width="200">Title <a href="index.php?order=title">^</a> v</td> <td width="110">Developer ^ v</td> <td width="140">Publisher ^ v</td> <td width="140">Year ^ v</td> <td width="140">Purchased ^ v</td> <td width="88">Genre ^ v</td> <td width="120">Serial ^ v</td> </tr> </table> <?php // Connect to the DB server $dbcnx = @mysql_connect('localhost', 'x', 'x'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } // Select the binarydr_stuff DB if (!@mysql_select_db('binarydr_stuff')) { exit('<p>Unable to locate the stuff ' . 'database at this time.</p>'); } // Request the text of all the info $result = @mysql_query('SELECT * FROM games');
if (!$result) { exit('<p>Error performing query: ' . mysql_error() . '</p>'); } // Display each game while ($row = mysql_fetch_array($result)) { echo ' <table class="cells"> <tr> <td width="85">' . $row['system'] . '</td> <td width="200">' . $row['title'] . '</td> <td width="110">' . $row['developer'] . '</td> <td width="140">' . $row['publisher'] . '</td> <td width="140">' . $row['year'] . '</td> <td width="140">' . $row['purchased'] . '</td> <td width="88">' . $row['genre'] .'</td> <td width="120">' . $row['serial'] .'</td> </tr> </table> '; } $order = isset($_GET['order']) ? mysql_escape_string($_GET['order']) : 'system'; // Request the text of all the info $result1 = @mysql_query( "SELECT system,title,developer,publisher, year,purchased,genre,serial FROM games ORDER BY $order DESC" ); // When clicked, this link will load this page with the hook sub form displayed echo '<div class="button_area"> <p>[ <a href="add.php">Add a Game</a> | <a href="../search/index.php">Search</a> | <a href="../">Home</a> | <a href="' . $_SERVER['PHP_SELF'] . '">Refresh</a> ]</p></div> </div> </div>'; ?> </body> </html>
|
|
|