Question
Subtract calculation
I have a function that calculates the remaining amount from
an entered value and the total value in the database:
<?php
function updateTotal()
{
$totalled = ($row_total_cost['Total_Bal'] - $_REQUEST['paid']);
return $totalled;
}
updateTotal();
?>
<form id="form2" name="form2" method="post" action="<?php echo updateTotal(); ?>">
<table width="500" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td width="30" valign="top">Paid:</td>
<td width="152" valign="top"><input type="text" name="paid" id="paid" /></td>
<td width="136" valign="top">New Balance:</td>
<td width="143" valign="top"><?php echo updateTotal();?></td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top"> </td>
<td valign="top"><input type="submit" name="update" id="update" value="Update" /></td>
<td valign="top"> </td>
</tr>
</table>
</form>
What am I doing wrong?
<?php
function updateTotal()
{
$totalled = ($row_total_cost['Total_Bal'] - $_REQUEST['paid']);
return $totalled;
}
updateTotal();
?>
<form id="form2" name="form2" method="post" action="<?php echo updateTotal(); ?>">
<table width="500" border="0" align="center" cellpadding="3" cellspacing="3">
<tr>
<td width="30" valign="top">Paid:</td>
<td width="152" valign="top"><input type="text" name="paid" id="paid" /></td>
<td width="136" valign="top">New Balance:</td>
<td width="143" valign="top"><?php echo updateTotal();?></td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top"> </td>
<td valign="top"><input type="submit" name="update" id="update" value="Update" /></td>
<td valign="top"> </td>
</tr>
</table>
</form>
What am I doing wrong?
