Prova così e vedi che errore ti da:
Codice PHP:
<?php
$host = "localhost";
$db_user = "root";
$db_password = " ";
$db_name = "siti-web";
$table_to_view = "siti-web";
$connect = mysql_connect($host, $db_user, $db_password) or die ("Errore di connessione: ".mysql_error());
$db = mysql_select_db($db_name, $connect);
$query = "SELECT * FROM $db_name.$table_to_view";
$result = mysql_query($query, $connect) or die ("Errore nella query: ".mysql_error());
echo("<table style=\"border-collapse:collapse;\">\n<thead>\n<tr>\n");
$first_row = true;
while ($row = mysql_fetch_assoc($result)) {
if ($first_row) {
foreach(array_keys($row) as $th) {
echo("<th style=\"border:1px solid #000000;\">[b] ".$th." [/b]</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");
?>