gpt4 book ai didi

php - 为什么这不会输出 MySQL Artist 表中的所有数据?

转载 作者:行者123 更新时间:2023-11-29 21:11:22 24 4
gpt4 key购买 nike

我编写了一个非常简单的查询来输出 Artist 表中的所有数据并将它们输出到已建立的表中。我已经仔细检查了数据库,所有拼写都是正确的,但由于某种原因我没有得到任何数据输出。

连接器代码

<?php

$conn = mysqli_connect("localhost", "b4014107", "Windows1", "b4014107_db2") or die (mysqli_connect_error());

?>

主要代码

!DOCTYPE HTML>
<html>
<head>
<title>View Artist Table</title>
</head>
<body>

<?php
//Includes speicifed details in order to connect to MySQL
include('ConnectorCode.php');

//mysql_query command is used to select data from Artist table
$result = mysqli_query("SELECT * FROM tbl_Artist");

echo "<table border='1'>";
echo "<tr> <th>Artist ID</th> <th>Artist Name</th> </tr>";

//Results are looped and then displayed in tables
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row ['Artist_id'] . "</td>";
echo "<td>" . $row ['Artist_Name'] . "</td>";
echo "</tr>";
}

echo "</table>";

//Connection is closed
mysqli_close($conn);


?>

<p><a href="ArtistNew.php">Add a new Artist</a></p>
<p><a href="ArtistEdit.php">Edit a current Artist</a></p>
</body>
</html>

我做错了什么?

最佳答案

我认为这是你的问题:

使用:$result->fetch_assoc()

而不是:mysqli_fetch_array($result)

关于php - 为什么这不会输出 MySQL Artist 表中的所有数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36338357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com