嘿所有我被困在使用php在我的webapge上显示一个表。每当我尝试新的东西时,我似乎都会遇到新的错误。我真的卡在这里我试图显示一个表客户端,其中包含列ID,名称,电话,电子邮件。我似乎无法将数据输入表中。有人可以帮忙使用mysqli吗?
<?php
include 'connect.php';
include 'form.php';
echo "<table border=1>";
echo "<tr><th>Id</th><th>Name</th><th>Phone</th><th>Email</th></tr>";
if($result = $mysqli_query("SELECT * from Client")){
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
echo "<tr><td>";
echo $row["ID"];
echo "</td><td>";
echo $row["name"];
echo "</td><td>";
echo $row["email"];
echo "</td><td><a href=delclient.php?id=";
echo $row["id"];
echo ">DEL</a> ";
echo "<a href=addclient.php?id=";
echo $row["id"];
echo ">EDIT</a>";
echo "</td></tr>";
}
echo "</table>";
}
?>
答案 0 :(得分:0)
而不是mysqli_query
,它应该是if($result = mysqli_query("SELECT * FROM Client")) {
:
.art-header
{
margin: 0 auto;
height: 80px;
background-image: url('../images/header.jpg');
background-position: center top;
background-repeat: no-repeat;
position: fixed;
z-index: auto !important;
}
答案 1 :(得分:0)
正如特里斯坦指出的那样,你的电话$mysqli_query()
是错误的;它应该是
$mysqli->query("SELECT * from Client")
或
mysqli_query($conn, "SELECT * from Client")
其中$conn
是在connect.php
中创建的数据库连接。鉴于您使用对象语法来引用结果字段,我怀疑上面的第一个是正确的。