I trying to build a calculator which will use a certain formula which will echo out the answer. I have an HTML form which gets the inputs and goes to the calc.php page and echos out the answer. I have this code but still cannot get it working. My html code [code]
Calculator <?php echo form_close();?>
</form>
[/code]
And this is my PHP code. [php]function calculate($num1, $num2, $num3)
{
$data = array() ;
$data[‘c’] = $num1 / 50;
$data[‘b’] = $num2 / 12;
$data[‘s’] = $num3 / 5;
$data[‘p’] = $data[‘c’] + $data[‘b’] - $data[‘s’];
if($data['s'] > 4)
{
$data['s']= 4;
}
return $data ;
}
if (isset($_REQUEST[‘value’])) //Additional checks should be done tho.
{
$num1 = $_REQUEST[“num1”];
$num2 = $_REQUEST[“num2”];
$num3 = $_REQUEST[“num3”];
$data = calculate($num1, $num2, $num3) ;
echo "{$data['c']} + {$data['b']} - {$data['s']} = {$data['p']}" ;
}[/php]
Thank you for all help in advance.