有谁知道为什么这段代码不起作用=
<html>
<head>
<title>Retrieve data from database </title>
</head>
<body>
<?php
include('connection.php');
$sqlget = "SELECT navcode FROM nav";
$sqldata = mysqli_query($dbcon, $sqlget) or die ('error gettting request');
echo "<table>";
echo "<tr><th>navcode</th></tr></table>";
while($row = mysqli_fetch_arrary($sqldata, MYSQLI_ASSOC)) {
echo "<tr><td>";
echo $row['navcode'];
echo "</td></tr>";}
echo "</table>";
?>
</body>
</html>
我的数据库有数据,但查询页面显示为空白。我错过了什么吗?
答案 0 :(得分:2)
看起来你拼错了mysqli_fetch_array
...
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
而不是
while($row = mysqli_fetch_arrary($sqldata, MYSQLI_ASSOC)) {