Jump to content

Problem showing top 10 highest score


Recommended Posts

I made a database in MySQL and made a database connection true php to show the data on the browser and it all works fine but the problem start when I only want show the top 10 highest score.


I tried


$result = mysql_query("SELECT top 10 ID, Naam, sum(Score) FROM Scores");


But it does not work it does really noting:(


Below is my code.


$username = "root";
$password = "";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("Oefentoets1",$dbhandle)
  or die("Could not select examples");

//execute the SQL query and return records
$result = mysql_query("SELECT ID, Naam, Score FROM Scores");

//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
   echo "ID: ".$row{'ID'}. " Naam: ".$row{'Naam'}." Score: ". //display the results
//close the connection

Edited by Arcadia
Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

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

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.