Learn Web Design, Coding & More. No Risk. No Contracts. Learn More

Here is a small PHP snippet to easily create a table in PHP.

First create the draw_table function.

$rows = 10; // amout of tr 
$cols = 10;// amjount of td 
function drawTable($rows, $cols){
echo "<table border='1'>"; 

    echo "<tr>"; 
               echo "<td align='center'>".$tr*$td."</td>"; 
    echo "</tr>"; 

echo "</table>";

To draw the table on your page use the function we just created.

drawTable(30, 10);

This will create a table with 30 rows and 10 columns.

Website templates and themes

Share the wealth

Keep updated with the latest tutorials and snippets.