Click here to Skip to main content
15,566,114 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I do not know how to do the following, need help with it

Have a table in mysql with columns, but I need the following columns fees_1, fees_2, fees_3, fees_4 and fees_5, to be sum in my html table in only one column Fees_bnb.

Using php and javascript.

Any help on how to do this will be apricated

Did try this, but it only sum up the first fees1


What I have tried:

PHP
<pre><td>
      <?php
      $fees1 = $num1 = $checkSqlRow["FEES_1"];
      $fees2 = $num2 = $checkSqlRow["FEES_2"];
      $fees3 = $num3 = $checkSqlRow["FEES_3"];
      $fees4 = $num4 = $checkSqlRow["FEES_4"];
      $fees5 = $num5 = $checkSqlRow["FEES_5"];
      $fees6 = $num1 + $sum2 + $sum3 + $sum4 + $sum5;
      echo $fees6;
    ?>
   </td>   
Posted
Updated 23-Jul-22 5:01am

1 solution

Just use SQL:
SQL
SELECT FEES_1, FEES_2, FEES_3, FEES_4, FEES_5,
       FEES_1 + FEES_2 + FEES_3 + FEES_4 + FEES_5 AS Total
  FROM MyTable
 
Share this answer
 
Comments
Odiez Bez 23-Jul-22 10:45am    
Thank you, did try it, but not sure what to use

<pre><td>
										
										<?php
										
										$checkSql = mysqli_query("SELECT FEES_1, FEES_2, FEES_3, FEES_4, FEES_5,
											FEES_1 + FEES_2 + FEES_3 + FEES_4 + FEES_5 AS Total FROM nmc_my_munte");
										
										$total = 
										echo $total;
										
										?>
										</td>	

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900