<!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=utf-8" />
<title>Mod</title>
</head>
<body>
<form action="modlima.php" method="post">
<div>
<select name="selected">
<option value="2">2</option>
<?php
$i = 2;
while($i < 61) {
$value = ($i +1);
echo("<option value=".$value.">".$i."</option>");
$i++;
}
?>
</select>
Fibonacci Numbers
</div>
<div>
<select name="columns">
<option value="3">3</option>
<?php
$i = 4;
while($i < 16) {
$value = $i;
echo("<option value=".$value.">".$value."</option>");
$i++;
}
?>
</select>
Columns
</div>
<input type="submit" name="submit" value="Update" />
</form>
<?php
$add1 = 1;
$add2 = 2;
$mod = 0;
$index = 3;
$max = 0;
if(isset($_POST['selected'])) {
$max = $_POST['selected'];
} else {
$max = 16;
}
if($max == 0) {$max = 2;}
if(isset($_POST['columns'])) {
$mod = $_POST['columns'];
} else {
$mod = 3;
}
if($mod == 0) {$mod = 1;}
echo("<table border=1><tr><td>1</td><td>2</td>");
while($index < $max) {
$sum = $add1 + $add2;
echo("<td>".$sum);
if(($index%$mod)==0) {echo("</td></tr>");} else {echo("</td>");}
$add1 = $add2;
$add2 = $sum;
$index++;
}
if((($index-1)%$mod)==0) {echo("</table>");} else {echo("</tr></table>");}
?>
</body>
</html>
Tidak ada komentar:
Posting Komentar