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 Quote Link to comment 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; ?> Quote Link to comment Share on other sites More sharing options...
mraza Posted August 17, 2010 Author Share Posted August 17, 2010 Thank you it works Quote Link to comment Share on other sites More sharing options...
mraza Posted August 17, 2010 Author Share Posted August 17, 2010 nvm solved 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.