Jump to content

[SOLVED] Quick Question


paulman888888

Recommended Posts

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

Link to comment
Share on other sites

<?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'>";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.