Jump to content

Archived

This topic is now archived and is closed to further replies.

Noctagon

resource id #

Recommended Posts

Hi all,

I am pretty new to this stuff still and have done a bit of searching but can't make sense out of stuff yet.

I have code as follows:

[code] $query = 'SELECT totals FROM alpha where UserID="1"';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

echo "$result";[/code]

I want it to look in the table called alpha at the column called totals and return me the entry where on the same row under the userid column the value is 1

I keep getting a resource id # result.......

How do I adjust things.

Thanks :)

Share this post


Link to post
Share on other sites
when you assign the query to a variable, the query returns a result source. It's like a magician's hat where it's dark and mysterious inside and you can pull out all kinds of crazy things like row data and rabbits and stuff.  So in order to pull the rabbit out of the hat, you must reach in and fetch it.  Here is one example of how to do that:

[code]
$query = 'SELECT totals FROM alpha where UserID="1"';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($list = mysql_fetch_array($result)) {
  echo $list['totals'] . "<br>";
}
[/code]

Share this post


Link to post
Share on other sites
Thankyou so much for your reply......exactly what I required........nice metaphor too as I am a magician ;)

Share this post


Link to post
Share on other sites

×

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.