Advertisement
arijulianto

Tabel Kolom Baris PHP

Feb 3rd, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Cetak Table</title>
  4. </head>
  5. <body>
  6. <form action="" method="POST">
  7.     <table border="1">
  8.     <tr>
  9.         <td colspan="2" align="center">Input Data</td>
  10.     </tr>
  11.     <tr>
  12.         <td>Kolom</td>
  13.         <td><input type="text" name="kolom" value="" /></td>
  14.     </tr>
  15.     <tr>
  16.         <td>Baris</td>
  17.         <td><input type="text" name="baris" value="" /></td>
  18.     </tr>
  19.     <tr>
  20.         <td colspan="2" align="right"><input type="submit" name="proses" value="PROSES" /></td>
  21.     </tr>
  22.     </table>
  23. </form>
  24. </body>
  25. </html>
  26. <?php
  27. if(isset($_POST['proses'])){
  28. $kolom = (int)$_POST['kolom'];
  29. $baris = (int)$_POST['baris'];
  30. echo "<table border=1>";
  31. for($row=1;$row<=$baris;$row++){
  32.     echo "<tr>";
  33.     for($col=1;$col<=$kolom;$col++){
  34.         echo "<td>kolom $col baris $row</td>";
  35.     }
  36.     echo "</tr>";
  37. }
  38. echo "</table>";
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement