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 Link to comment https://forums.phpfreaks.com/topic/107966-solved-only-10/ 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#'); Link to comment https://forums.phpfreaks.com/topic/107966-solved-only-10/#findComment-553351 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? Link to comment https://forums.phpfreaks.com/topic/107966-solved-only-10/#findComment-553353 Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Share Posted May 30, 2008 top 10 Link to comment https://forums.phpfreaks.com/topic/107966-solved-only-10/#findComment-553354 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#'); Link to comment https://forums.phpfreaks.com/topic/107966-solved-only-10/#findComment-553378 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.