paulman888888 Posted June 4, 2008 Share Posted June 4, 2008 i have my php script but i would like to order my list relervent to the $_get['order'] (or if there isnt anything in $_get['order'] show all in order with highest score 1st) but i dont know how to input this into my script. eg something.php?order=ipaddress i would like it to be ordered by ipaddress. <?php // Get all the data from the "myscore2" table $result = mysql_query("SELECT * FROM myscore2 ORDER BY score DESC"); echo "<table border='1'>"; echo "<tr><th>ID</th><th>Name</th><th>Score</th><th>Ipaddress</th><th>Game id</th><th>The Date</th><th>Mode</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr>\n"; echo "<td><a href='delete.php?id=".$row['id']."'>".$row['id']."</a></td>\n"; echo "<td>".$row['name']."</td>\n"; echo "<td>".$row['score']."</td>\n"; echo "<td>".$row['ipaddress']."</td>\n"; echo "<td>".$row['gameid']."</td>\n"; echo "<td>".$row['thedate']."</td>\n"; echo "<td>".$row['mode']."</td>\n"; echo "</tr>\n"; } echo "</table>"; ?> Thankyou Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 4, 2008 Share Posted June 4, 2008 <?php // Get sort method $sort = isset($_GET['order']) ? mysql_real_escape_string($_GET['order']) : 'score'; // Get all the data from the "myscore2" table $result = mysql_query("SELECT * FROM myscore2 ORDER BY `{$sort}` DESC"); echo "<table border='1'>"; Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 4, 2008 Share Posted June 4, 2008 Im afraid im not even going to bother to read your 'Quick question'. Your last one wasn't, so i've no reason to assume this one is. Please make the effort to give a more discriptive title to the problem if you'd like me to make the effort to answer it. Quote Link to comment Share on other sites More sharing options...
revraz Posted June 4, 2008 Share Posted June 4, 2008 Insert 1 header row in your HTML Table with labels. Make the labels URL's that set the order by, and then do either IF statements or SWITCH to determine the sort order. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.