Jump to content

[SOLVED] Very quick & easy question about MySQL select query


Chappers

Recommended Posts

Hi,

 

Embarrassingly, as it's been a few months since I tinkered with my code, I can't remember how to do this simple thing: When I've grabbed just one piece of data from a MySQL table, how do I display it?

 

$query = ("SELECT age FROM members WHERE username='".$_SESSION['username']."'");

$result = mysql_query($query);

echo ????????

 

Each username is unique so I know there is only one piece of data to be retrieved but can't for the life of me remember how to access it afterwards.

 

Thanks for helping.

Thanks for that. For some reason I was sure I didn't need to do mysql_fetch_assoc if there was only one result being retrieved, I was thinking that's only for when more than one column was being retrieved from a row, such as in this example age and gender, for instance.

 

Thanks again, back on track now and able to continue what I was doing.

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.