tangga - 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.
Result of php executing
Full code of tangga.php
- <!DOCTYPE html>
- <html>
- <head>
- <title>Tangga Warna</title>
- <style>
- body{
- background-color: red;
- font-family: cursive;
- }
- .tangga{
- height: 10px;
- width: 10px;
- display: inline-block;
- border: 1px solid black;
- }
- button{
- background-color: black;
- color: white;
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <form method="post" action="">
- <table>
- <tr>
- <th>Tangga Berwarna</th>
- </tr>
- <tr>
- <td>Jumlah Anak Tangga</td>
- <td><input type="text" name="jumlah"></td>
- </tr>
- <tr>
- <td>Warna</td>
- <td><input type="radio" name="warna" value="green">Hijau
- <input type="radio" name="warna" value="purple">Ungu
- <input type="radio" name="warna" value="yellow">Kuning
- <input type="radio" name="warna" value="blue">Biru
- <input type="radio" name="warna" value="grey">Abu</td>
- </tr>
- <tr>
- <td><button type="submit">Buat Tangga</button></td>
- </tr>
- </table>
- </form>
- <?php
- $jumlah = (int)$_POST['jumlah'];
- $warna = $_POST['warna'];
- for ($i=1; $i <= $jumlah ; $i++) {
- for ($a=1; $a <= $i ; $a++) {
- echo <<<aw
- <div class="tangga" style="background-color:$warna">
- </div>
- aw;;
- }
- echo "<br>";
- }
- ?>
- </body>
- </html>
File Description
- tangga
- PHP Code
- 29 Oct-2019
- 1.24 Kb
You can Share it:
Latest PHP Pastes