开发者

PHP calculator script

开发者 https://www.devze.com 2023-03-10 03:13 出处:网络
I\'ve been looking all over for 开发者_开发百科a sample script, but I haven\'t been able to find one.Basically, I want to have the code get a value from a div and multiply that number based on the use

I've been looking all over for 开发者_开发百科a sample script, but I haven't been able to find one. Basically, I want to have the code get a value from a div and multiply that number based on the user input. For example, if I have a site for recipes, and I want to have a calculator where the user enters the amount of servings that they need, and it'll change the recipe to give the amount of servings specified. (you can see an example HERE.)


you have to use $_POST or $_GET

To get the users input.

Then you can manipulate it according to your needs and then display it back to the users using echo


i think you can solve the problem with Javascript too ! if you are using PHP then do like this

if (isset($_POST['num1'],$_POST['num2'],$_POST['operator']))
{
 ...
}

if you do not use ISSET it will show warnings that $_POST is undefined or so...

0

精彩评论

暂无评论...
验证码 换一张
取 消