Friday, July 31, 2009

PHP help please?

Here's the code:


--------------------------------------...


%26lt;?PHP


$XXX = 500; //value can be input numerous ways


$A = $XXX - (($XXX * 0.034)+0.3);


$B = $A - ($A * 0.1);


$C = $B* 1.1;


$D = $C - (($C* 0.025) + 5);


$E = $D * 7827;


echo number_format($E);


// show your answer in this formate show 688,413





?%26gt;


--------------------------------------...


* originally helped by,


catbertnc and Mohd.SAQIB Q.. Thanks Guys!!





Now further question:


What's the input syntax, so i will have a box,


like a search box, where i can key in various input numbers.


And when i click "calculate" it will echoes E.





What i mean is to have a web page, with an input box and calculate button.


And when pressed will automatically shows the result.





Thank you verryyy much.. :D

PHP help please?
Ok, the easiest way requires two scripts. I'll call the first one form.php and the second calculate.php. The first holds the form the user will use, and the second will perform the calculations.





form.php


---------------


%26lt;?php


echo "%26lt;form action='calculate.php' method=POST%26gt;";


echo "Number: %26lt;input type=text name='xxx'%26gt;%26lt;BR%26gt;";


echo "%26lt;input type=submit value='Calculate'%26gt;";


?%26gt;


-------


calculate.php


--------------


%26lt;?PHP


$XXX = $_POST['xxx'];


$A = $XXX - (($XXX * 0.034)+0.3);


$B = $A - ($A * 0.1);


$C = $B* 1.1;


$D = $C - (($C* 0.025) + 5);


$E = $D * 7827;


echo number_format($E);


// show your answer in this formate show 688,413





?%26gt;





That should do it.
Reply:i dunno, lol
Reply:PHP have no way to input from the user, for that matter any server side script would have to use HTML to display or fetch user data, either by AJAX or form.


No comments:

Post a Comment