Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute PHP Online

<html>
    <head>
 
        <title>Create Table Dynamically</title>
        <style>
            
        </style>
    </head>
 
    <body>
        <form method="post" action ="main.php">
            <table border="1" width="350px">
                <tr>
                    <td>Enter number of Rows</td>
                    <td><input type="text" name="rows"/></td>
                </tr>
                <tr>
                    <td>Enter number of Columns</td>
                    <td><input type="text" name="columns"/></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                    <input type="submit" value="Create Table" name="create"/>
                    </td>
                </tr>
            </table>
        </form>    
        
        
            <span style="color:red"></span>
<?php
if(isset($_REQUEST['create']))
    { ?>
  <span class="comments">
    <?php $row=$_REQUEST['rows']; ?>
 <span class="comments"></span>
<?php $col=$_REQUEST['columns']; ?>
     <span class="comments"> </span>
        <?php echo "<table border='1' width='350px'>";
        for($i=1;$i<=$row;$i++)
        { ?>
 <span class="comments"></span>
        <?php    echo "<tr>";
            for($j=1;$j<=$col;$j++)
            { ?>
              <span class="comments"></span>
            <?php echo "<td>row".$i."col".$j."</td>";
            } ?>
                       <span class="comments"></span>
            <?php echo "</tr>";
            
        } ?>
       <span class="comments"></span>
        <?php echo "</table>";    
    } ?>
<span style="color:red"></span>
        
        
    </body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.