Hello,
i m new one in php/mysql, i m facing problem to calculate the two fields, in my database i have two fields the one is "debit" and second one is "credit"(and third one is (may be wrong) "Balance")
Now i m wana to subtract "debit" from "credit" and then store the result in the "Balance", and at the end i also wana to get the sum of "Debit" , "Credit" and "Balance".
So plz if any one have best idea to solve this matter, will be appreciated.
Regards.

Hi ismael ahm@d and welcome to DaniWeb :)

You probably don't need to store the balance in the database as you can calculate this very easily on the fly in PHP, but if you really want to you just do a simple update statement on the database. Something like this:

UPDATE balances_table
SET balance = credit - debit

To calculate the sum of your data, you use a SUM() query, like so:

SELECT SUM(debit) as debits FROM balances_table
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.