Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

I'm creating a program that prompts the user for 2 different positive integers, then prints out the numbers between the 2 integers (inclusive) and the

$
0
0

HERE IS MY CODE:

_____________

 

Machine1.html

_____________

 

<!DOCTYPE>
<html>
<head>
</head>
<body>
<form method="get" action="MachineTemplate.php">
Enter a NUM1:<input type="text" name="num1" value="">
Enter a NUM2:<input type="text" name="num2" value="">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
__________________
 
MachineTemplate.php
__________________
<!DOCTYPE>
<html>
<head>
<title>MACHINE TEMPLATE</title>
</head>
<body>
<h2>Middle Squared</h2>
<?php
$a =$_REQUEST ['num1'];
$b =$_REQUEST ['num2'];
 
 
for ($i=$a+1; $i < $b; $i++)
{
$squared = $i * $i;
echo ($i . "=" . $squared . "<br>");
 
 
}
?>
</body>
</html>
 
 
and this is the output:
 
 
Middle Squared

2=4
3=9
4=16
5=25
6=36
7=49
8=64
9=81

 

 

But I can't get the sum of all the squared. Can you help me? Anyone? Thanks so Much! 

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles