Noctagon Posted October 2, 2006 Share Posted October 2, 2006 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 1I keep getting a resource id # result.......How do I adjust things.Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/22712-resource-id/ Share on other sites More sharing options...
.josh Posted October 2, 2006 Share Posted October 2, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22712-resource-id/#findComment-102120 Share on other sites More sharing options...
Noctagon Posted October 2, 2006 Author Share Posted October 2, 2006 Thankyou so much for your reply......exactly what I required........nice metaphor too as I am a magician ;) Quote Link to comment https://forums.phpfreaks.com/topic/22712-resource-id/#findComment-102751 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.