mraza Posted August 17, 2010 Share Posted August 17, 2010 hi i need to get value after Multiplication in a loop as total, plz how can i do that here is my code while ($row = mysql_fetch_array($name)) {?> <td><?php echo $row['service']; ?></td> <td><?php echo $result['qty'] ; ?></td> <td><?php echo $total = ($result['qty'] * $row['price']); ?></td> <?php } ?> i need to get $total of sum after loop, currently it shows only individual.. thanks for any help.. Regards Link to comment https://forums.phpfreaks.com/topic/210921-getting-multiplication-value-in-a-loop/ Share on other sites More sharing options...
Pikachu2000 Posted August 17, 2010 Share Posted August 17, 2010 You can add each total while in the loop to keep a running total, then echo it when the loop completes. while ($row = mysql_fetch_array($name)) {?> <td><?php echo $row['service']; ?></td> <td><?php echo $result['qty'] ; ?></td> <td><?php echo $total = ($result['qty'] * $row['price']); ?></td> $running += $total <?php } echo $running; ?> Link to comment https://forums.phpfreaks.com/topic/210921-getting-multiplication-value-in-a-loop/#findComment-1100155 Share on other sites More sharing options...
mraza Posted August 17, 2010 Author Share Posted August 17, 2010 Thank you it works Link to comment https://forums.phpfreaks.com/topic/210921-getting-multiplication-value-in-a-loop/#findComment-1100157 Share on other sites More sharing options...
mraza Posted August 17, 2010 Author Share Posted August 17, 2010 nvm solved Link to comment https://forums.phpfreaks.com/topic/210921-getting-multiplication-value-in-a-loop/#findComment-1100262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.