<html>
    <head>
        <title>For Loop Nested</title>
        <link href="//yorktown.cbe.wwu.edu/sandvig/mis314/assignments/style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div class="pageContainer centerText">
            <h2>For Loop Nested</h2><hr>
            <form>
                <p>Iterations:<br>
                    <label>Rows: <input type="text" name="rows" size="5" autofocus></label><br>
                    <label>Cols: <input type="text" name="cols" size="5"></label>
                    <input type="submit" value="Loop">
                </p>
            </form>
            <?php 
                if (isset($_GET['rows']) && isset($_GET['cols']) 
                        && is_numeric($_GET['rows']) && is_numeric($_GET['cols'])) {
                    $max_row = intval($_GET['rows']);
                    $max_col = intval($_GET['cols']);
                    echo "<div class=\"rows\">";
                    echo "<table class=\"simpleTable\">";
                    for ($i = 1; $i < $max_row + 1; $i++) {
                        echo "<tr>";
                        for ($j = 1; $j < $max_col + 1; $j++) {
                            echo "<td>Row: $i, Column: $j</td>";
                        }
                        echo "</tr>";
                    }
                    echo "</table>";
                    echo "</div>";
                } elseif (isset($_GET['rows']) && isset($_GET['cols'])) {
                    echo "<h3>Please enter an integer.</h3>";
                }
            ?>
        </div>
    </body>
</html>
