简体   繁体   中英

How to MINUS sum of values from sum of values php and mysql

am very new in php, and I have serious question to get the answer, I hope you will help me.

I have a table on mysql named "Payment" with the following fields

(School_fee  |  Fee_setting  |  Trans_port  |   trans_setting)

in fields setting of all fields i set the actual total amount of money which student suppose to pay for appropriate service per 3 month, and student can pay for installment, So guys I want when I set may be 100000 at once in fee_setting, and when student come and pay 20000 as School_fee the amount will be reducted each time when student pay a school_fee . this means (fee_setting) it will reduct total number of school_fee payed by a certain student.

I have the codes but this reduct only first student and others student the results comes with negative sign(-), Am confused i don't know where the problems is.

Here the codes:

echo $results['SUM(fee_setting)'] - $results ['SUM(school_fee)']."</td>";   

我认为您需要abs()来避免出现负值:

echo abs($results['SUM(fee_setting)'] - $results ['SUM(school_fee)'])."</td>";   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM