3 回答

TA貢獻1840條經(jīng)驗 獲得超5個贊
您需要先調(diào)用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,該文檔顯示在頁面頂部附近(在主要說明區(qū)域中)...

TA貢獻1891條經(jīng)驗 獲得超3個贊
嘗試$num_of_rows在if(statement)之后-在bind_param之前設置您的權限...除非那會改變您的結果。沒有更多信息很難說。

TA貢獻1827條經(jīng)驗 獲得超9個贊
您的查詢似乎出了點問題。嘗試進行直接查詢,例如if($stmt = $mysqli->query("SELECT id, title, visible, parent_id FROM content WHERE parent_id = YOURIDHERE ORDER BY page_order ASC;")){,看看是否仍然可以解決0個結果
添加回答
舉報