How to print mysql data in table format using php

,

Here is the code

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "search";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

$sql = "Select * from keywords";

$result=mysqli_query($conn,$sql);
print "<table width='100%'>";
print "<thead>";
print "<th>Id</th>";
print "<th>Keyword</th>";
print "<th>Count</th>";
print "<thead>";
print "<tbody align='center'>";
while ($row = $result->fetch_row()) {
print '<tr>';
print "<td>".$row[0]."</td>";
print "<td>".$row[1]."</td>";
print "<td>".$row[2]."</td>";
print '</tr>';
}
print "</tbody>";
print "</table>";
?>


Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.