在下面的代码中,我可以通过使用while循环(在代码中注释)来回显bind_result中的$ count。但我希望将该值保存在$ count变量中以进行进一步处理,而不是仅仅打印该值。如何保持$ count的值?
/*......mysqli connection...*/
$stmt =$mysqli->prepare("select count(*) from tab where rtd_id=? ");
$stmt->bind_param('i',$id);
$id = 1;
$stmt->execute();
$stmt->bind_result($count);
/*while($stmt->fetch())
{
echo $count;
}*/
if($count>0)
{
//DO SOMETHING
}
?>
答案 0 :(得分:0)
首先,你不需要在这里循环。
$stmt->bind_result($count);
$stmt->fetch();
if($count>0)
{
//DO SOMETHING
}