Jump to content

Recommended Posts

Hello, I need the script to be able to only pick the 50 best scores, and not every score that is submitted.

Any idea? It has to be the 50 best of course, not just randomly 50.

Is it something that can be fixed with > or is it abit more advance code?

 

<html>
<head>
<link href="styleofc.css" rel="stylesheet" type="text/css">
</head>
<center>
<div style="position:absolute; margin-left:450px; margin-top:0px; TOP:100px; color:#D8D8D8;" border="2" >
<?php
$con = mysql_connect("loff-production.com.mysql","loff_production","v4rANidp");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_select_db("loff_production", $con);
$result = mysql_query("SELECT name, score FROM high_scores_avoidthecars ORDER BY score DESC");

echo "<table border='20'>
<tr>
<th>Name</th>
<th>Score</th>
</tr>";
while($row = mysql_fetch_array($result))
 {

 echo "<tr>";
 echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['name'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>";
 echo "<td>" .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. $row['score'] .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp'. "</td>";
 echo "</tr>";
 }
echo "</table>";

mysql_close($con);
?>
</div>
</center>
</html>

Link to comment
https://forums.phpfreaks.com/topic/271239-1-50-table-database-sorting/
Share on other sites

least you got the code tags this time ;) You really should be learing SQL, this is seriuosly basic stuff.

SELECT name, score FROM high_scores_avoidthecars ORDER BY score DESC LIMIT 50

Thanks and yeah, I'm rarily using this stuff but it sure would be handy to know it.

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.