Jump to content

form field calculations and mysql


wrigd411

Recommended Posts

I am a php newbie and 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 in total-don't ask). I did manage to create a few 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.

Link to comment
Share on other sites

I think I understand what your going for, just to be sure could you post your code please?

 

also code like this:

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

 

what is ttl_inc? have you already defined $inc1, $inc2, $inc3 through post variables above this code?

Edited by mike12255
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.