Jump to content

Problem showing top 10 highest score


Arcadia

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.

<?php

$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
   $row{'Score'}."<br>";
}
//close the connection
mysql_close($dbhandle);


?>
Link to comment
https://forums.phpfreaks.com/topic/295304-problem-showing-top-10-highest-score/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.