Rabu, 16 Maret 2011

tugas modul 6 B


PHP Source code

<!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>Untitled Document</title>
</head>

<body><center>
<?php

$html = '<html>
<head>
<title>php tabel generated</title>
</head>

<body>
<form method="post">
<p> <strong>CEL count : </strong>
<input name="cel" type="text" value="10" /></p>
<p> <strong>COL count : </strong>
<input name="col" type="text" value="4" /></p>
<p> <input type="submit" name="click" value="Generate" /></p>
</form>';

$clicked = $_POST['click'];
if (isset($clicked)) {
$cel = (int) $_POST['cel'];
$col = (int) $_POST['col'];

$html.= '<table border="1px" cellspacing="0">
<tr>';
for ($count=1; $count<=$cel; $count++) {
$html.= '<td width=\"50\" height=\"50\">
<div align="center">'.$count.'</div>
</td>';
if ($count % $col == 0) $html.= '</tr><tr>';
}
$html.= '</tr>
</table>';
}

$html.= '</body>
</html>';

echo $html;

?></center></body>
</html>

Tidak ada komentar:

Posting Komentar