Hello, I am trying to create a loop that increase the radius of a circle by a certain percent (10%) every cycle (5 times in total). The radius is entered by the user.
I am trying to get the area of a circle to increase, by increasing the radius by 10% every cycle of a loop. I have started the script and have not managed to do it. The script below only increases the radius by 1 every loop.
<html>
<title>test</title>
</head>
<body>
<h1>test</h1>
<?php
$times = 5;
$i = 0;
$x = 0;
print '<hr />';
function getnum() {
$strThisPage = $SERVER['PHP_SELF'];
print '<form name="form1" method="post" action='.$strThisPage.'>';
print 'Number 1: <input type="text" name="number1" value=""><p />';
print '<p><input type="submit" /></p>';
print '</form>';
return;
}
if ($SERVER['REQUEST_METHOD'] != 'POST') {
getnum();
print '<hr />';
}
else {
$intNumber1 = $_POST['number1'];
$radius = $intNumber1;
$area = pi() * pow($radius, 2);
}
{
while ($x <= 5) {
$area++;
$x++;
print "Area of the circle is $area";
}
}
?>
</body>
</html>
Can someone please explain to me how to increase the radius (and thus the area by 10%) every loop?
P.S. I am also getting an error - "Notice: Undefined variable: area". Could someone please explain why I am getting that error? Thanks. Any help would be great.