Loop in PHP

Learn Loops in PHP

Division

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Division Table Using Loop</title>
</head>

<body>
<?php
$start_num = 1;
$end_num = 10;
?>
<center><H2>A division table</H2>
<TABLE BORDER=1>
<?php
print(“<TR>”);
print(“<TH> </TH>”);
for ($count_1 = $start_num;$count_1 <= $end_num; $count_1++)
print(“<TH>$count_1</TH>”);
print(“</TR>”);

for ($count_1 = $start_num ; $count_1 <= $end_num; $count_1++)
{
print(“<TR><TH>$count_1</TH>”);
for ($count_2 = $start_num; $count_2 <= $end_num; $count_2++)
{
$result = $count_1 / $count_2;
printf(“<TD>%.3f</TD>”, $result);
}
print(“</TR>\n”);
}
?>
</TABLE>
</center></BODY>
</HTML>
</body>
</html>

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.