I want to extract all records from PostgreSQL DB table and display those data using table in HTML without specifying the column name. I have many tables with many columns, so I want my query in HTML to be as responsive as it can.
Using this code below, I'm able to query the data from my database and print the data on browser, but I have to specify which column that I want to display.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8">
<title>Map</title>
</head>
<body onload="init()">
<h1>Map</h1>
<div>
<?php
$conn = pg_connect("host=localhost port=5432 dbname=visualization user=postgres password=*******");
$result = pg_query($conn,"SELECT * FROM myTable");
echo "<table>";
while($row=pg_fetch_assoc($result)){
echo "<tr>";
echo "<td align='center' width='200'>" . $row['lon'] . "</td>"; // set col manually
echo "<td align='center' width='200'>" . $row['lat'] . "</td>"; // set col manually
echo "</tr>";
}
echo "</table>";
pg_close($conn);
?>
</div>
</body>
</html>
Here's the result :
I only display 2 columns because I specified the column manually. I want to display all columns in the table with its records without specifying it manually (up to 100 columns). How to achieve that?

pg_field_namein the PHP manual - it shows an example which might be of interest - php.net/manual/en/function.pg-field-name.php