No. 2

Test PT indotara persada
mail@pastecode.io avatar
unknown
php
2 months ago
838 B
3
Indexable
Never
<!DOCTYPE html>
<html>
<head>
    <title>Perkalian Berulang</title>
</head>
<body>
    <h2>Perkalian Berulang</h2>
    <form action="index.php" method="post">
        <label for="number">Masukan Angka:</label>
        <input type="number" id="number" name="number" required>
        <input type="submit" value="Submit" name="submit">
        <input type="reset" value="Reset">
    </form>

    <?php
    if(isset($_POST["submit"])) {
        $number = $_POST["number"];

        echo "<h3>Hasil Perkalian untuk Angka $number:</h3>";
        echo "<ul>";
        for ($i = 1; $i <= $number; $i++) {
            for ($j = 1; $j <= $number; $j++) {
                $result = $i * $j;
                echo "<li>$i x $j = $result</li>";
            }
        }
        echo "</ul>";
    }
    ?>
</body>
</html>
Leave a Comment