...

View Full Version : Advice on "Current Bank Amount" needed - Counting..



Hardist
07-25-2012, 07:28 AM
Sorry for the lame title. What I need is some advice on how to do what I want to do. I have made my own administration "program" in PHP, where I can also insert expenses and incomes, and invoices and such which I am getting. I have one table in the database called "bank" with one field called "current". Each time I am adding an income into the database, the amount I enter will be added to the "current" field. Whenever I enter an expense, it will be substracted.

But, whenever I make some typo, I need to edit the stuff. I have an edit page where I can easily edit the income or expense amount that I entered before. But that also means I need to add or substract the changes from the "current" field aswell. This isn't really the best way I guess, but I didn't try it yet to do it like this to be honest.

Another way is to simply use php to add every income and substract every expense, and display what's left as a total current bank amount. But also that I think wouldn't really be the best way.

Any ideas of how to handle this easily? You can also post some code snippets if you would like to, but I don't really need any difficult codes and such, I just need an idea for a simple solution which I can work out myself.

Thanks in advance for any replies I will be getting :)

connormcwood
07-25-2012, 12:41 PM
Isn't this the type of stuff excel was created for? Sorry for the short reply, I just think you should use that instead of going threw all the hassle of making your own Php script.

Rowsdower!
07-25-2012, 01:33 PM
One idea:

Put in a starting "bank" amount in your database and never touch it again. Then, when you want to get your current balance you can query the sum (http://www.tizag.com/mysqlTutorial/mysqlsum.php) of all credits and debits in your database and add that figure to your original balance. Then if you make a typo when entering a credit or debit you're only ever going to have to go back and edit that one credit/debit transaction (just as you are right now) and your bank balance will automatically follow.

Hardist
07-26-2012, 06:47 AM
Isn't this the type of stuff excel was created for? Sorry for the short reply, I just think you should use that instead of going threw all the hassle of making your own Php script.

Sorry for my comment also, but if I wanted to use Excel, I would've. Besides, there's a lot more in my "php admin program" than just what I described above.


One idea:

Put in a starting "bank" amount in your database and never touch it again. Then, when you want to get your current balance you can query the sum (http://www.tizag.com/mysqlTutorial/mysqlsum.php) of all credits and debits in your database and add that figure to your original balance. Then if you make a typo when entering a credit or debit you're only ever going to have to go back and edit that one credit/debit transaction (just as you are right now) and your bank balance will automatically follow.

I am kind of doing that right now aswell yes, but I hadn't thought of this before yet. Sounds like a plan to simply in the beginning of august or september when I start using the program, to just put in that starting amount of that month, and then when I am inserting and editing, to do what you just said, to use the sum. Hadn't thought of it like that before, so thanks very much, this will help me :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum