Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.