【发布时间】:2018-12-22 03:01:10
【问题描述】:
我有猫,我有帖子,这是我的代码:
<?php
$sel_query = "SELECT * FROM cats ORDER BY cat_id ASC";
$result = mysqli_query($con,$sel_query);
while($data = mysqli_fetch_assoc($result))
{ // start insert cats
echo "<h1>Cat Name: ".$data["cat_id"]."</h1>";
$sel_query2 = "SELECT * FROM selecom WHERE cel_cat='".$data['cat_id']."' ";
$result2 = mysqli_query($con,$sel_query2);
while ($data2 = mysqli_fetch_assoc($result2))
{ // start insert posts
echo "<h2>Post: ".$data2['cel_golid']."</h2>";
echo "<h2>total Post Numbers in this cat: ?????????????????????????????????</h2>";
}
}
?>
我需要插入总帖子编号(放置问号)
示例: 如果某只猫有 2 个帖子,我想在(问号的位置)2 中写帖子的数量
*如果翻译不清楚,我很抱歉
【问题讨论】:
-
你试过 $result2->num_rows; ?
标签: php