3 回答
TA贡献1840条经验 获得超5个赞
您需要先调用MySqli_Stmt::store_result()num_rows查找:
if($stmt = $mysqli->prepare("SELECT id, title, visible, parent_id FROM content WHERE parent_id = ? ORDER BY page_order ASC;")){
$stmt->bind_param('s', $data->id);
$stmt->execute();
$stmt->store_result(); <-- This needs to be called here!
$num_of_rows = $stmt->num_rows;
$stmt->bind_result($child_id, $child_title, $child_visible, $child_parent);
while($stmt->fetch()){
//code
}
echo($num_of_rows);
$stmt->close();
}
请参阅上的文档MySQLi_Stmt->num_rows,该文档显示在页面顶部附近(在主要说明区域中)...
TA贡献1827条经验 获得超9个赞
您的查询似乎出了点问题。尝试进行直接查询,例如if($stmt = $mysqli->query("SELECT id, title, visible, parent_id FROM content WHERE parent_id = YOURIDHERE ORDER BY page_order ASC;")){,看看是否仍然可以解决0个结果
添加回答
举报