我创建了一个函数名dispcategories()
,在函数内部我创建了一些代码来显示category_title
和其他东西,但是我收到了这个错误
警告:mysqli_fetch_assoc()要求参数1为mysqli_result,在第7行的.......中给出布尔值
这是function.php中的代码
function dispcategories() {
include ('dbconn.php');
$select = mysqli_query($con, "SELECT * FROM categories");
while ($row = mysqli_fetch_assoc($select)) {
echo "<table class='category-table'>";
echo "<tr><td class='main-category' colspan='2'>".$row['category_title']."</td></tr>";
dispsubcategories($row['cat_id']);
echo "</table>";
}
}
并在index.php中
<div class="content">
<?php dispcategories(); ?>
</div>
答案 0 :(得分:0)
更改
while ($row = mysqli_fetch_assoc($select)) {
到
while ($row = $select->fetch_assoc()){