[Solved] How do I create tables dynamically from user input? [closed]


Copy and paste into a php page, place the column and lines in text fields click the Create Table button, keep testing and looking at the source code that one day you’ll understand.

<?php
    $table="";
    if ($_POST) {
        $table .= '<table border="1">';
        for ($i = 0; $i < $_POST['qty_line']; $i++) {
            $table .= '<tr>';
            for ($j = 0; $j < $_POST['qty_colunn']; $j++) {
                $table .= '<td width="50">&nbsp;</td>';
            }
            $table .= '</tr>';
        }
        $table .= '</table>';
    }
?>
    <form action="" method="post">
        <table border="0" width="200">
            <tr>
                <td width="80"><label>Column</label></td>
                <td width="120"><input type="text" name="qty_colunn"></td>
            </tr>
            <tr>
                <td><label>Line</label></td>
                <td><input type="text" name="qty_line"></td>
            </tr>
            <tr>
                <td colspan="2" align="right"><input type="submit" value="Create Table"></td>
            </tr>
        </table>    
    </form>
    <br />
    <br />
<?php
    echo $table;
?>

0

solved How do I create tables dynamically from user input? [closed]