xoligy Posted February 25, 2010 Share Posted February 25, 2010 Ok the query works in phpmyadmin but soon as i add it to the php i get Resource id #24 can someone tell me whats up or explain? What i want, is for the query to count how many of an item the user has so if a user had 10 of id 1 and then 20 of id 5 it would echo the quantity. Im sure i could make it more complecated but i dont think thats necassary Breakdown: Weapon info is stored in Melee. Userweapons is how many of each weapon the user has which is matched up to melee "id" via "item_id" The user is matched by "user_id" and in this query id 1 will be changed to "$id" Hope this makes sense $qty = mysql_query("select melee.item, userweapons.item_id, userweapons.qty, userweapons.user_id from melee, userweapons where melee.id = userweapons.item_id and userweapons.user_id=1"); $result = mysql_query($qty) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['item_id']. " - ". $row['qty']; echo "<br />"; } Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 25, 2010 Share Posted February 25, 2010 What are you getting in your $row? put a print_r($row); in your loop and it will show you. I think that is likely to supply your answer Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 25, 2010 Share Posted February 25, 2010 $qty = "select melee.item, userweapons.item_id, userweapons.qty, userweapons.user_id from melee, userweapons where melee.id = userweapons.item_id and userweapons.user_id=1"; $result = mysql_query($qty) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
xoligy Posted February 25, 2010 Author Share Posted February 25, 2010 $qty = "select melee.item, userweapons.item_id, userweapons.qty, userweapons.user_id from melee, userweapons where melee.id = userweapons.item_id and userweapons.user_id=1"; $result = mysql_query($qty) or die(mysql_error()); Thanks Mchl! i'll look it over and see what was wrong So adding "mysql_query("")" waws the problem ok lol thanks Quote Link to comment 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.