Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Advice on "Current Bank Amount" needed - Counting..

    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

  • #2
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    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.
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials

  • #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    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 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.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • The Following 2 Users Say Thank You to Rowsdower! For This Useful Post:

    connormcwood (07-25-2012), Hardist (07-26-2012)

  • #4
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by connormcwood View Post
    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.

    Quote Originally Posted by Rowsdower! View Post
    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 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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •