<?php
$host="localhost";
$db_user="root";
$db_password=" ";
$db_name="siti-web";
$table_to_view="siti-web";
$conn=mysql_connect($host,$db_user,$db_password);
if($conn==false) die("Errore di connessione al db");
$table=mysql_query("SELECT * FROM $db_name.$table_to_view",$conn);
if($table==false) die("Errore query");
echo("<table style=\"border-collapse:collapse;\">\n<thead>\n<tr>\n");
$first_row=true;
while($row=mysql_fetch_assoc($table)){
if($first_row){
foreach(array_keys($row) as $th){
echo("<th style=\"border:1px solid #000000;\">".$th."</th>\n");
}
$first_row=false;
echo("</tr>\n</thead>\n<tbody>\n");
}
echo("<tr>\n");
foreach($row as $cell){
echo("<td style=\"border:1px solid #000000;\">$cell</td>\n");
}
echo("</tr>\n");
}
echo("</tbody>\n</table>\n");
?>