vomitbomb Posted May 11, 2008 Share Posted May 11, 2008 Hey there, I'm putting together an ordering system and at certain points in the system the user wants to see how many of a particular item has been ordered so they can have the correct amount of stock. Any thoughts on how to do this? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 11, 2008 Share Posted May 11, 2008 give this a try <?php // grab the info from the database $query = mysql_query("SELECT * FROM `table` WHERE `userid`='23' ") or die("Problem with query"); // grab all the columns in the table $row = mysql_fetch_array($query); // count how many items are in the table $items = mysql_num_rows($query); // display the items echo $row['itemname'] . "<br>"; echo "<hr>"; // display the amount of items echo $items; ?> Regards ACE Quote Link to comment Share on other sites More sharing options...
vomitbomb Posted May 11, 2008 Author Share Posted May 11, 2008 Some entries may have say 15 and others may have 1, I'm not looking at how many entries there is, but the sum of all the entry values added up in a certain COLUMN.. Will this do that? (sorry I'm just learning) example: Say I want the sum of all the GREEN values which is 34. Will that code do it for me? id blue yellow green 0 5 3 9 1 2 3 3 2 7 2 6 3 9 1 7 4 1 4 7 5 6 6 2 Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted May 11, 2008 Share Posted May 11, 2008 whats the current code you have? and hows the table set up in the database? Quote Link to comment Share on other sites More sharing options...
vomitbomb Posted May 11, 2008 Author Share Posted May 11, 2008 I haven't started the php yet, just trying to get idea's on how it's all going to work. I put an example in the post above so I hope what I'm asking makes more sense now. Ok I've just realised I meant COLUMN not row, sorry. Quote Link to comment Share on other sites More sharing options...
vomitbomb Posted May 12, 2008 Author Share Posted May 12, 2008 Any idea's on this one? 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.