I am trying to make a program where users can input a starting number, ending number, and the increment amount. The program should confirm each value is numeric and then square it and return it and then increase by the increment amount. The program does 1 operation and then stops if I put in an end value of less than 10 but doesnt run at all if its more than 10. I am a student and my prof. is gone for the next two weeks. Any feedback would be helpful, thanks.
For example
Start Value: 5
End Value: 20
Increment: 5
Your results should be:
5 squared is 25
10 squared is 100
15 squared is 225
20 squared is 400
<?php
$endValue = $_POST['endValue'];
$startValue = $_POST['startValue'];
$incValue = $_POST['incValue'];
if (is_numeric($endValue))
{
for ($startValue = $startValue; $startValue <= $endValue; $startValue = $incValue * $incValue);
{
print("<p> testing $startValue </p>");
}
}
else
{
print("<p> Bad input - use a number </p>");
print("<p><a href=\"squared.html\"> return </a></p>" );
}
?>
$startValue, not set it to the same value each iteration. Dofor ( ..; ..; $startValue += $incValue)instead. And clean up that indentation :-)