Jump to content

Recommended Posts

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;






?>

Link to comment
https://forums.phpfreaks.com/topic/193520-array-sum-i-have-a-headache/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.