using php to return specific data from mysql
Posted: Sun Nov 09, 2003 2:42 pm
hey there!
I'm trying to return a piece of data from a MySQL database and print it on the screen using the echo command.
I want this to appear on the screen:
GOLD : 'then the number of gold, say 1254 etc.'
So this is the command i use to display that
<?php echo "Gold: $gold" ?>
That will work fine, but it's getting the data assigned to the variable gold in a readable format thats the problem. I've tried doing something like this:
$gold_query = "SELECT gold
FROM player
WHERE username = $_COOKIE['user_name']";
$gold_result = mysql_query($gold_query);
$gold = mysql_result($gold_result);
why doesn't that work? The cookie has already been set by the way, i just need to work out how to pull the data out of the databse and assign it to the variable $gold.
Thanks in advance...
I'm trying to return a piece of data from a MySQL database and print it on the screen using the echo command.
I want this to appear on the screen:
GOLD : 'then the number of gold, say 1254 etc.'
So this is the command i use to display that
<?php echo "Gold: $gold" ?>
That will work fine, but it's getting the data assigned to the variable gold in a readable format thats the problem. I've tried doing something like this:
$gold_query = "SELECT gold
FROM player
WHERE username = $_COOKIE['user_name']";
$gold_result = mysql_query($gold_query);
$gold = mysql_result($gold_result);
why doesn't that work? The cookie has already been set by the way, i just need to work out how to pull the data out of the databse and assign it to the variable $gold.
Thanks in advance...