PHP Basics

Create Table in webpage using PHP Code

The power of PHP is it can easily embed HTML Codes. To create any html elements lets say a table, we can use PHP to create a table.

Create Table Using PHP

We have to echo out all the table tags and its respective data.

Note: If you are looking for a solution to create a table inside mysql using PHP, then check this article: Use SQL in PHP

Example

<?php

$output=”<table>”;

$output.=”<tr><td>Sures</td><td>112000</td><td>Engineer</td></tr>”;

$output.=”<tr><td>John</td><td>142000</td><td>Contractor</td></tr>”;

$output.=”<tr><td>Simran</td><td>113400</td><td>Asst. Engineer</td></tr>”;

$output.=”<tr><td>Raju</td><td>112000</td><td>Plan Executor</td></tr>”;

$output.=”<tr><td>Sneha</td><td>182000</td><td>Architecture</td></tr>”;

$output.=”</table>”;

echo $output;

?>

output:

Sures 112000 Engineer
John 142000 Contractor
Simran 113400 Asst. Engineer
Raju 112000 Plan Executor
Sneha 182000 Architecture