berikut kodenya:
<!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></title>
</head>
<body>
<?php
echo "Contoh 12 sel 3 kolom<br />";
cetakTabel(12, 3);
echo "<br />Contoh 10 sel 4 kolom<br />";
cetakTabel(10, 4);
?>
<?php
function cetakTabel($sel, $kolom) {
echo '<table border="1">';
for($i = 1; $i <= $sel; $i++) {
if($i % $kolom == 1) {
echo '<tr>';
}
echo '<td width="30px" height="30px">' . $i . '</td>';
if ($i % $kolom == 0 || $i == $sel ) {
echo '</tr>';
}
}
echo '</table>';
}
?>
</body>
</html>
dan trata hi hi hi inilah hasilnya
he he he gagal
Tidak ada komentar:
Posting Komentar