Step 1:
Create data base connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "search";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
Step 2:
Select the table
$sql = "Select * from keywords";
Step 3:
Get the table header values from database
$result=mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
$x = array_keys($row);
Step 4:
Print the headers value
foreach($x as $rows)
{
print $rows.'<br >';
}
Final 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);
$row = mysqli_fetch_assoc($result);
$x = array_keys($row);
foreach($x as $rows)
{
print $rows.'<br >';
}
?>