How can i fix my endless PHP loop?

  • Thread starter Thread starter Hello
  • Start date Start date
H

Hello

Guest
Every time i run it, it just keeps running and running. I have to stop it using task manager. What is wrong?

Also, is this code right? This program is suppose to display a list of numbers and their squares from the starting number to the ending number and increments according to the increment provided by the user.

this is my code:

<html>
<head>
<title>Squares</title>
<link rel ="stylesheet" type="text/css" href="sample.css" />
</head>

<body>

<?php
$startNum = $_POST['startNum'];
$endNum = $_POST['endNum'];
$increment = $_POST['increment'];

print ("<h1>SQUARES</h1><hr />");

print ("<hr />");

print ("<h1>SQUARES</h1><hr />");
print ("<hr />");

for ($counter = $startNum; $countet <= $endNum; $counter = $counter + $increment )
{
$square = $counter * $counter;
print("The square of $counter is $square <br/>");
}
//end for
?>

</body>
</html>
 
Back
Top