Jump to content

Only echoes one?


3raser

Recommended Posts

Here is my current PHP & MySQL code:

 

<?php

mysql_connect("db4free.net","isrbuckey55","pgpg7755opcd") or die("Connection failed!");
mysql_select_db("isrbuckey55") or die("Database fail!");

//display data
$get = mysql_query("SELECT * FROM views");
while ($row = mysql_fetch_assoc($get))

{
// get data
$time = $row['seconds'];
}

echo "Total gameplay seconds: ". $time ."<br><Br><br>";


//display data
$get = mysql_query("SELECT * FROM scores ORDER BY score DESC");
while ($row = mysql_fetch_assoc($get))

{
// get data
$score = $row['score'];
$username = $row['username'];
}

echo "The user ". $username ." got a score of ". $score ."";
?>

 

Website link; http://z-o-cheats.webuda.com/

 

Why does it only display ONE highscore?

Link to comment
https://forums.phpfreaks.com/topic/191114-only-echoes-one/
Share on other sites

Because you only echo out that last result:

 

while ($row = mysql_fetch_assoc($get)) {
// echo data
echo "The user ". $row['username'] ." got a score of ". $row['score'] ."";
}

 

Since there are multiple data you have to iterate through the results to print it and or collect them all into a multi-dimensional array and loop / iterate through that.

Link to comment
https://forums.phpfreaks.com/topic/191114-only-echoes-one/#findComment-1007731
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.