paulman888888 Posted May 30, 2008 Share Posted May 30, 2008 hi, I have a little problem. Can you help me show only 10 scores please? <?php // Get all the data from the "example" table $result = mysql_query("SELECT * FROM example ORDER BY score DESC") or die('O no. Theres an error#'); echo ""; echo ""; // 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 ""; echo $row['score']; echo "#"; } echo "#Completed"; ?> I know it shows a # but i want that their because my game interpates it as a newline. Thankyou Paul Quote Link to comment Share on other sites More sharing options...
jk11uk Posted May 30, 2008 Share Posted May 30, 2008 hey you should use the 'limit' thing in your SQL so it only gets 10 rows. like this i think: $result = mysql_query("SELECT * FROM example ORDER BY score DESC LIMIT 0, 10") or die('O no. Theres an error#'); Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted May 30, 2008 Author Share Posted May 30, 2008 would it get the highest ten or any random ten? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Share Posted May 30, 2008 top 10 Quote Link to comment Share on other sites More sharing options...
tapos Posted May 30, 2008 Share Posted May 30, 2008 if u want top 10 then u use jk11uk reply. if u want to put pull any then they u must set the start offset instead of 0 //this will pull the data from 1 to 10 $result = mysql_query("SELECT * FROM example ORDER BY score DESC LIMIT 0, 10") or die('O no. Theres an error#'); // this will pull the data from 11 to 10 $result = mysql_query("SELECT * FROM example ORDER BY score DESC LIMIT 10, 10") or die('O no. Theres an error#'); 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.