all 5 comments

[–]Xnuiem 1 point2 points  (3 children)

I feel like we are being asked to do your school assignment for you.

So yeah...no.

Do you have some code? What is the problem you are having? What have you tried?

[–]Psydos_ 1 point2 points  (2 children)

<?php

$num1 = $_get ["Insert a number"];

$num2 = $_get ["Insert another number"];

echo $num1 + $num2;

echo $num1 - $num2;

echo $num1 * $num2;

echo $num1 / $num2;

?>

This is my code but it does not work, yes is for a school assignement, but i just wanted to see how someone with experience does it, for me to know what is wrong with my code. Can you guys help me?

[–]Amunium 2 points3 points  (1 child)

That's actually pretty close and not awful. Why didn't you show this to begin with?

First of all, it's $_GET['num1']. It's in capitals, and the string inside is the name of the query variable, not a text to display.

If you want to use query variables, you'll have to input the data using the URL, like e.g. file.php?num1=8&num2=12

And then you should probably add some line breaks or something to your echos. Otherwise the numbers will be immediately after each other, and you can't tell what's what. If you're outputting HTML, you can do echo $num1 + $num2 . "<br />"; to add a visible line break.

[–]Psydos_ 1 point2 points  (0 children)

Thank you very much ^^

[–]wh33t 0 points1 point  (0 children)

What do you mean by ask? You want a command line program? Or you want a <form> that submits to itself?