How to Print HTML Table Using PHP

Today i am going to say you how to print HTML table using PHP. Important of this method is if you are trying to display results retried from the database you can easily display it by using PHP ‘s  echo function.Lets we see how to do it.

This is how the out put will be on your web browser

Code.

<?php

        echo "<table border='4' class='stats' cellspacing='0'>

            <tr>
            <td class='hed' colspan='8'>WELCOME TO HTML TABLES</td>
              </tr>
            <tr>
            <th>ID</th>
            <th>FIRST NAME</th>
            <th>LAST NAME</th>
            <th>ADDRESS</th>
            <th>TELEPHONE</th>

            </tr>";

              echo "<tr>";
              echo "<td>" . "001" . "</td>";
              echo "<td>" . "Damith" . "</td>";
              echo "<td>" . "Wanninayake" . "</td>";
              echo "<td>" . "Uva wellassa University" . "</td>";
              echo "<td>" . "1234567890" . "</td>";

              echo "</tr>";

              echo "<tr>";
              echo "<td>" . "001" . "</td>";
              echo "<td>" . "Damith" . "</td>";
              echo "<td>" . "Wanninayake" . "</td>";
              echo "<td>" . "Uva wellassa University" . "</td>";
              echo "<td>" . "1234567890" . "</td>";

              echo "</tr>";

              echo "<tr>";
              echo "<td>" . "001" . "</td>";
              echo "<td>" . "Damith" . "</td>";
              echo "<td>" . "Wanninayake" . "</td>";
              echo "<td>" . "Uva wellassa University" . "</td>";
              echo "<td>" . "1234567890" . "</td>";

              echo "</tr>";

    echo "</table>";

?>

The above code is out put the so called table using PHP. Try this on your database projects.