想知道是否有人可以帮我解决这个问题。我在第20行(开头的行:while($ row = mysqli_fetch ...)
谢谢! :)
<?php
function dispcategories() {
include ('connection.php');
$select = mysqli_query($DBconnect, "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>";
}
}
function dispsubcategories($parent_id) {
include ('connection.php');
$select = mysqli_query($DBconnect, "SELECT cat_id, subcat_id, subcategory_title, subcategory_desc FROM categories, subcategories
WHERE ($parent_id = categories.cat_id) AND ($parent_id = subcategories.parent_id)");
echo "<tr><th width='90%'>Categories</th><th width='10%'>Topics</th></tr>";
while ($row = mysqli_fetch_assoc($select)) {
echo "<tr><td class='category_title'><a href='/forum-tutorial/topics/".$row['cat_id']."/".$row['subcat_id']."'>
".$row['subcategory_title']."<br />";
echo $row['subcategory_desc']."</a></td>";
echo "<td class='num-topics'>".getnumtopics($parent_id, $row['subcat_id'])."</td></tr>";
}
}
答案 0 :(得分:0)
为了按照你想要的方式做你正在做的事情,你需要将MYSQLI_USE_RESULT
标志传递给查询:
$select = mysqli_query($DBconnect, "SELECT cat_id, subcat_id, subcategory_title, subcategory_desc FROM categories, subcategories
WHERE ($parent_id = categories.cat_id) AND ($parent_id = subcategories.parent_id)", MYSQLI_USE_RESULT);