所以我做了我的第一个数据库在线。我用phpmyadmin,我创建了表和用户。
现在我想在我的网站的某个页面上显示该表格,并且可以让用户从该网站编辑数据库。
我的问题是数据库无法正常工作:它没有连接。我不知道该怎么做。
我的数据库称为letstenf_santi和我的表passeggeri。 这是我试图用来在网站上显示表格的代码。MySQL似乎没有工作
<?php
//establishing connection
mysql_connect('localhost', 'root', '');
//selecting a database
mysql_select_db('letstenf_santi');
$sql = 'SELECT * FROM `letstenf_santi`.`passeggeri`';
$records=mysql_query($sql);
?>
<html>
<head>
<title>mostra</title>
</head>
<body>
<table width="300" border="1" cellpadding="10" cellspacing="1">
<tr>
<th>id pass</th>
<th>nome</th>
<th>eta</th>
<th>sesso</th>
</tr>
<?php
while($pass=mysql_fetch_assoc($records)){
echo "<tr>";
echo "<td>".$pass['idpasseggero']."</td>";
echo "<td>".$pass['nome']."</td>";
echo "<td>".$pass['eta']."</td>";
echo "<td>".$pass['sesso']."</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
弃用语法检测 –
什么是你得到的错误? –
无。它只是不起作用。我不知道该怎么办 – gab