Hi All,

As the title says.
Have been looking for solution these past 2 days,
Salary Record are pulled from database (MySql) in to PHP table (do/while loop).

- Name , Salary , OvertimePay , Subtotal , MedicalDeduct , UnionFeeDeduct , Tax , Grand Total
- Peter , 1300 , 200 , Subtotal(1500) , 100 , 100 , 50 , Grand Total(1250)
- Mary , 1200 , 200...
- Tom , 1500...

I populate the record into rows of textbox, so user can edit them to save into another table.

Question:

1. How do I calculate the Subtotal and Grand Total in each row?
What is the approach I should take?
2. How do I submit the result into new table? Can I loop the insert statement?

Any help greatly appreciated. Thanks.

Hi All,

As the title says.
Have been looking for solution these past 2 days,
Salary Record are pulled from database (MySql) in to PHP table (do/while loop).

- Name , Salary , OvertimePay , Subtotal , MedicalDeduct , UnionFeeDeduct , Tax , Grand Total
- Peter , 1300 , 200 , Subtotal(1500) , 100 , 100 , 50 , Grand Total(1250)
- Mary , 1200 , 200...
- Tom , 1500...

I populate the record into rows of textbox, so user can edit them to save into another table.

Question:

1. How do I calculate the Subtotal and Grand Total in each row?
What is the approach I should take?
2. How do I submit the result into new table? Can I loop the insert statement?

Any help greatly appreciated. Thanks.

Nevermind, have solved the problem.
Hope this helps anyone in need.

1. Count Row output from database
E.g. $count = mysql_num_rows(**recordset**)
2. Output data into table, each textbox name should be named as array.
E.g. <input name="txt_salary[]" type="text" id="txt_salary[]" value="<?php **output database record** ?>">
3. Do your calculation in additional textbox through php
4. Loop the Insert Statement with the count from step 1
for($i = 0; $i < $count; $i++){
$row1 = $_POST[$i];
**do other calculation**
**insert record statement**
}

Cheers