Jump to content

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


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.

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.