Jump to content

[SOLVED] Loop?


PHPNS

Recommended Posts

Hi All!

My first post here. 

I'm trying to make a custom shipping cost calculator where the calculator finds each row(item and quantity) from a shopping cart table, but I'm stuck on the loop.  As it is so far I've been able to create the code so that it finds each item in the cart and weight(s), however I need a secondary loop (I think?) that adds each fetched row's weight together as a total weight.  Understand??

Here's a snippet of what I have:

 

while ($row = mysql_fetch_assoc($result)) {

 

$weight = $row['pd_weight'] * $row['ct_qty'];

 

 

}

 

So basically this code will output each products weight, as seperate rows.  Can someone help me add a loop in here that will add each row together, afterwards, as a total weight??

I'm relatively new to programming and the loops get me everytime.

 

Please help!!

Link to comment
https://forums.phpfreaks.com/topic/46472-solved-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.