Tugas Praktikum 6 (PHP) - Buat Tabel Based on User Input
Eko Fahrudi Silviawan
100533406929
S1 PTI Off F
Value yang diinputkan otomatis akan diingat ketika tombol "Buat Tabel" kita tekan.
Download Source Code
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> <p> <strong>Tugas Praktikum 6 (PHP) - Buat Tabel Based on User Input</strong><br> Eko Fahrudi Silviawan<br>100533406929<br>S1 PTI Off F </p> <p>Value yang diinputkan otomatis akan diingat ketika tombol "<b>Buat Tabel</b>" kita tekan</p> <form id="form1" name="form1" method="post" action="TugasPrak6.php"> Jumlah Cell <input name="t1" type="text" id="t1" value="<?php echo $_POST['t1']; ?>" /><br> Jumlah Column <input name="t2" type="text" id="t2" value="<?php echo $_POST['t2']; ?>" /><br> <input type="submit" name="button" id="button" value="Buat Tabel" /> </form> <?php if ($button){ $var1 = $_POST['t1']; $var2 = $_POST['t2']; $a = $var1 % $var2; $b = $var1 - $a; $count = 0; echo "<table border=1>"; echo "<tr>"; for ($i=1;$i<=$b;$i++) { $count++; echo "<td align=\"center\" width=\"50\" height=\"50\">".$count."</td>"; if ($i % $var2 == 0) echo "</tr><tr>"; } echo "</tr>"; for ($i=1;$i<=$a;$i++) { $count++; echo "<td align=\"center\" width=\"50\" height=\"50\">".$count."</td>"; } echo "</tr>"; echo "</table>"; } ?> </body> </html> |
0 comments:
Post a Comment