Jump to content

[PHP][MYSQL]Display dynamic data from database


Rdogg112

Recommended Posts

true

 

this is wat i got so far

 

$sql = mysql_query("SELECT * FROM `users` WHERE `money` = $money") or die(mysql_error());
$blah = mysql_fetch_array($sql);
echo 'Money: '. $blah['money'];

 

but i dont know what to put in $money

+ i dont know if that code works.

i suggest you start with the basics.  like what you want to do with your game, and how to use SQL queries .

 

http://www.tizag.com/phpT/index.php

http://www.tizag.com/sqlTutorial/

 

Once you understand what you are talking about, then you can get specific help

  • 2 years later...

Your code is almost correct, you need to get the money based on the logged in users ID or username.

 

  $sql = mysql_query("SELECT money FROM `users` WHERE id = {$user['id']}");
  if($sql) {
    $blah = mysql_fetch_assoc($sql);
    echo 'Money: '. $blah['money'];
  } else }
    echo 'This Query Failed: '.mysql_error();
  }

 

Try the above, but change the $user['id'] to the method you are using to identify a user.

 

Regards, PaulRyan.

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.