PHP MySQL Variable Question?

Phil M

New member
First off I have a Main Menu - Then on the Main Menu I have a button to submit and GET data from a table called casesubmission. This table holds all of the Attorney Cases with filenumber, amountowed, etc.

Now what I am trying to do is to take a simple calculator code and turn it into a code that SUBTRACTS amountowed from casesubmission and UPDATE AND SET the amountowed WHERE filenumber equals filenumber. Now, the subtraction code is setup to echo num1 - num2; Is this the only way to get the result? I need num1 - num2 to be a result in a variable so I can tell the server to UPDATE casesubmission SET newamountowed = '$amountowed' WHERE filenumber = '$filenumber;
How do I get num1 minus num2 to equal newamountowed so I can update the database?
Keep this in mind too, On the Main Menu, you will submit to GET the file information, then once everything is echoed on VIEWCASE.PHP, then you will see the calculator along with the information. Probably also need to know how to carry the filenumber to be used in second query. Would I just say $filenumber = '$filenumber; Or $_POST['filenumber'];

Thos are the two issues I am having.
Thank you for the answers. What I did was $amountowed = $num1 - $numb2;

I also added a HIDDEN input to my form and called it filenumber with the value of PHP ECHO (echod the file number from Main Menu to View Case. I also added
$filenumber = mysqli_real_escape_string($dbc, trim($_POST['filenumber']));

and everything worked out great! It now subtracts the data and updates the database so I can post a payment made. Of course you must be logged in to do any of this and will refer to a specialist for security issues.

Thanks alot!
 
Maybe I'm missing something (seems very simple) but to answer the question:
"How do I get num1 minus num2 to equal newamountowed so I can update the database?"

$newamountowed = $num1-$num2;
 
Maybe I'm missing something (seems very simple) but to answer the question:
"How do I get num1 minus num2 to equal newamountowed so I can update the database?"

$newamountowed = $num1-$num2;
 
Maybe I'm missing something (seems very simple) but to answer the question:
"How do I get num1 minus num2 to equal newamountowed so I can update the database?"

$newamountowed = $num1-$num2;
 
Back
Top