for2 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of for2.php

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  <title>Studi Kasus For 2</title>
  5.  <style>
  6.   body{
  7.    background-color: cyan;
  8.    font-family: cursive;
  9.   }
  10.   input{
  11.    border-radius: 5px;
  12.   }
  13.   button{
  14.    background-color: red;
  15.    color: white;
  16.    border: 1px solid black;
  17.   }
  18.  
  19.  </style>
  20. </head>
  21. <body>
  22.  <form method="POST" action="">
  23.   <table>
  24. <tr>
  25.     <th colspan="3">Daftar Jurusan Siswa</th>
  26.    </tr>
  27. <tr>
  28.     <td>Masukkan jumlah Data:</td>
  29.     <td><input type="text" name="jumlah"></td>
  30.     <td><button type="submit">Ok</button></td>
  31.    </tr>
  32. </table>
  33. <br>
  34.  </form>
  35. <table border="1" cellspacing="0" cellpadding="5">
  36.   <?php 
  37.   $jumlah = (int)$_POST['jumlah'];
  38.   for($i=1;$i<=$jumlah;$i++){
  39.    echo <<<kok
  40. <tr>
  41.     <td>Nama</td>
  42.     <td><input type="text" name=""></td>
  43.     <td>Jurusan</td>
  44.     <td><input type="radio" name="jurusan">RPL</td>
  45.     <td><input type="radio" name="jurusan">TKJ</td>
  46.     <td><input type="radio" name="jurusan">MM</td>
  47.     <td><input type="radio" name="jurusan">AV</td>
  48.     <td><input type="radio" name="jurusan">TITL</td>
  49.     <td><input type="radio" name="jurusan">TOI</td>
  50.    </tr>
  51. kok;
  52.    }
  53.    ?>
  54.  </table>
  55. </body>
  56. </html>
File Description
  • for2
  • PHP Code
  • 29 Oct-2019
  • 1.17 Kb
You can Share it: