I currently have a PHP file that accesses my MySQL database and pulls out the Names and Scores for each player and stores them in an array.
//This query grabs the top 10 scores, sorting by score and timestamp.
$query = "SELECT * FROM Score ORDER by score DESC, ts ASC LIMIT 10";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
//We find our number of rows
$result_length = mysql_num_rows($result);
//And now iterate through our results
for($i = 0; $i < $result_length; $i++)
{
$row = mysql_fetch_array($result);
echo $row['name'] . "\t" . $row['score'] . "\n"; // And output them
}
What is the best way for me to get both the name and the score from the PHP File and store them in a Javascript Array?
$row?//Leaderboard $.get( "HighScores/TopScores.php", function(data) { var results = JSON.parse(data); console.log(2); results.forEach(function(result){ console.log( result.name +" - "+ result.score ); console.log(1) }); }, "json" );But my Game doesn't seem to print anything out to the Console, not Name, Scores, "1" or "2"?