phpstuck Posted February 26, 2010 Share Posted February 26, 2010 OK can someone please point me in the right direction... I have been through the manual, and all over google but I can't seem to figure this out. I have two tables, one is named inven the other is named groc In the inventory table there are food items made by different manufactures like Kroger canned corn, Aldi Canned Corn and Foodland Canned corn. each have a different "quan" They are linked by a sub cat in the "inven" table named groccat (all are set to "canned corn") Over in the "groc" table there is a grocname that is also "canned corn" and a column named "min" I am trying to get a sum from an array for all the different brands in the "inven" table that have a sub cat of "canned corn" So instead of 2 cans of kroger and 3 cans of Aldi... I can get 5 cans of corn. I have tried the following to no avail. along with a million other ways to try and put it together... Any help would be enough to get me moving again :-) <?PHP include_once 'db.php'; $deflist=mysql_query( "SELECT l.groccat, l.quant, b.grocname, b.min, b.tobuy FROM inven l,groc b WHERE l.groccat = b.grocname"); while ($all = mysql_fetch_array($deflist)) { $results[$all['groccat']][] = array ('quant' => $all['quant'], 'grocname' => $all['grocname'], 'min' => $all['min'], 'tobuy' => $all['buy']); } $newquant = SUM($all[;quant']); echo $newquant; ?> Quote Link to comment Share on other sites More sharing options...
phpstuck Posted February 27, 2010 Author Share Posted February 27, 2010 Ok I figured this part out.... Now the math is killing me :-( 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.