Calculate a total of TD

Calculate a total of TD

Hi,

I have below code to populate items from basket table. I want to know is it possible to calculate the item_quantity TD and show the total_sum or I should do it at MySQL level?

Thanks,
Jassim Rahma

  1. <div id="divBasket" style="background-color: #FFFFFF; margin-top: 50px; margin-right: 120px; border: 1px solid; border-radius: 25px; padding: 10px; width: 300px; float: right;">
  2. <table width="100%" cellspacing="10">
  3. <?php
  4. $session_id = $_SESSION["id"];
  5.     $mysql_query = $mysql_connection->prepare('CALL sp_populate_basket_items(:param_session_id)');
  6. $mysql_query->bindParam(':param_session_id', $session_id, PDO::PARAM_STR);
  7.     $mysql_query->execute();

  8.     while($mysql_row = $mysql_query->fetch())
  9.     {
  10. ?>
  11. <tr>
  12. <td class="item_name"><?php echo $mysql_row["item_name"]; ?></td>
  13.     <td class="item_quantity"><?php echo $mysql_row["item_quantity"]; ?></td>
  14.     <td class="item_price"><?php echo $mysql_row["item_price"]; ?></td>
  15. </tr>
  16. <?php } ?>
  17. <tr>
  18. <td colspan="3"><hr></td>
  19. </tr>
  20. <tr>
  21. <td align="right">Total :</td>
  22.     <td></td>
  23.     <td>TOTAL_SUM_FROm_JQUERY</td>
  24. </tr>
  25. <tr>
  26. <td align="center" colspan="3"><img src="images/buy_now.png"></td>
  27. </tr>
  28. </table>
  29. </div>