Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2013
    Thanked 0 Times in 0 Posts

    form field calculations and mysql

    I am a php newbie. I have a problem I just cannot figure out. I have a household income and expense calculator form (inc1, inc2, inc3, exp1, exp2, exp3, exp4)

    I need to calculate total income, total expenses, net income, potential savings and the largest expense category with values entered from the form.

    My calculations are:

    $ttl_inc_val = $_POST['ttl_inc] + $inc1 + $inc2 + $inc3;

    $ttl_exp_val = $_POST['ttl_exp + $exp1 + $exp2+ $exp3+ $exp4;

    $net_val = $_POST['net'] + $inc1 + $inc2 + $inc3 - $exp1 - $exp2 - $exp3 - $exp4;

    $p_svgs_val = $_POST['p_svgs'] + $net + $exp4;

    I still haven't figured out the how-to for the largest expense, but my problem at this point is that I cannot get any of these calculations to post to my database tables (6 tables in total-don't ask). I did manage to create a few mysql triggers that will calculate my ttl_inc on the income table and another for the expenses table. But that still leaves the other calculations and all are on different tables. I am sure it is probably something silly that I am missing, but I just cannot see it. Probably been staring at this far too long. Any help would be greatly appreciated.

  2. #2
    New Coder
    Join Date
    Aug 2012
    Thanked 0 Times in 0 Posts

    try this

    PHP Code:
    $exp2 11;
    $exp3 12;
    $exp4 13;
    $xs = array($exp1$exp2$exp3$exp4);
    works for me
    Last edited by Inigoesdr; 12-02-2013 at 09:39 PM.
    A talent for speaking differently, rather than for arguing well, is the chief instrument of cultural change. Richard Rorty


Tags for this Thread

Posting Permissions

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