Jump to content

grand total amount....


arunpatal

Recommended Posts

Hi,

 

i need to add total amount and echo it in page.

variable $total_price show total amount of 1 product

but i want to show grand total amount in page.....

 

Please help with this

 

<?php do { ?>

<?php

$total_price = $row_view_order['quantity'] * $row_view_order['price'];

if (isset($row_view_order['productid'])) {
echo '<tr>
 <td id="admin_list_first">'.$row_view_order['product_name'].'</td>
 <td id="admin_list">'.$row_view_order['quantity'].'</td>
 <td id="admin_list">'.$row_view_order['price'].'</td>
<td id="admin_list">'.$total_price.'</td>

</tr>'; }

 else {
	 echo '<tr>
 <td align="left" style="padding-left:10px;"><h3>Please Select Order from order list.</h3></td>
 <td></td>
 <td></td>
<td></td>
</tr>'; }
 ?>



<?php } while ($row_view_order = mysql_fetch_assoc($view_order)); ?>

Link to comment
https://forums.phpfreaks.com/topic/272742-grand-total-amount/
Share on other sites

Try this:

 


<?php

$grand_total = 0;

do {

$total_price = $row_view_order['quantity'] * $row_view_order['price'];

$grand_total += $total_price;

if (isset($row_view_order['productid'])) {
echo '<tr>
<td id="admin_list_first">'.$row_view_order['product_name'].'</td>
<td id="admin_list">'.$row_view_order['quantity'].'</td>
<td id="admin_list">'.$row_view_order['price'].'</td>
<td id="admin_list">'.$total_price.'</td>

</tr>'; }

else {
echo '<tr>
<td align="left" style="padding-left:10px;"><h3>Please Select Order from order list.</h3></td>
<td></td>
<td></td>
<td></td>
</tr>'; }
?>



<?php } while ($row_view_order = mysql_fetch_assoc($view_order));

echo 'Grand total: ' . $grand_total;

?>

 

Have a $grand_total variable and increase it with each product's total price (for every iteration of the loop, i.e. for every product) and then display the value of the variable when the loop terminates.

Link to comment
https://forums.phpfreaks.com/topic/272742-grand-total-amount/#findComment-1403511
Share on other sites

Try this:

 


<?php

$grand_total = 0;

do {

$total_price = $row_view_order['quantity'] * $row_view_order['price'];

$grand_total += $total_price;

if (isset($row_view_order['productid'])) {
echo '<tr>
<td id="admin_list_first">'.$row_view_order['product_name'].'</td>
<td id="admin_list">'.$row_view_order['quantity'].'</td>
<td id="admin_list">'.$row_view_order['price'].'</td>
<td id="admin_list">'.$total_price.'</td>

</tr>'; }

else {
echo '<tr>
<td align="left" style="padding-left:10px;"><h3>Please Select Order from order list.</h3></td>
<td></td>
<td></td>
<td></td>
</tr>'; }
?>



<?php } while ($row_view_order = mysql_fetch_assoc($view_order));

echo 'Grand total: ' . $grand_total;

?>

 

Have a $grand_total variable and increase it with each product's total price (for every iteration of the loop, i.e. for every product) and then display the value of the variable when the loop terminates.

 

 

Thanks Andy :)

it works

Link to comment
https://forums.phpfreaks.com/topic/272742-grand-total-amount/#findComment-1403583
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.