Selasa, 08 Maret 2011

tugas web modul 6

tugas rumah generate tabel

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Generate Tabel</title>
</head>
<body>
<h3 align="center" class="style1">GENERATE TABEL</h3>
<div align="center">
<?php $rows = 4; //baris?>
<?php $columns = 3; //kolom?>
<?php $argumen = 10; //alokasi banyaknya abel yang di isi?>
<?php
echo "<table width=200 height=300 border=1>";
$baris = 0;
$sel = 1;

// fungsi perulangan
while ($sel <= $argumen)
{ while ($baris < $rows)
{ echo "<tr>";
$kolom = 0;
while ($kolom < $columns)
{
if ($sel <= $argumen)
{ echo "<td><div align=center>".$sel."</div></td>";
$sel++;
}
$kolom++;
}
echo "</tr>";
$baris++;
}
}
echo "</table>";
?>
</div>
</body>
</html>

Tidak ada komentar:

Posting Komentar