2 回答
TA贡献1818条经验 获得超7个赞
删除$explore_image->store_result
.
并且不要忘记在完成后关闭准备好的语句和连接(按此顺序)。
根据您的初始代码:
$explore_image = $con->prepare('SELECT body, image FROM posts ORDER BY RAND()');
$explore_image->execute();
// $explore_image->store_result();
$explore_image->bind_result($body, $image);
// output data of each row
while ($explore_image->fetch())
{
if (!empty($image))
{
echo '<div id="rcorners2">';
echo "$body <img src='$image' id='explore_post_pic'></br><br><br><br></div><br>";
}
}
$explore_image -> close();
$con -> close();
TA贡献1865条经验 获得超7个赞
<?php
$explore_image = $con->prepare('SELECT body, image FROM posts ORDER BY RAND()');
$explore_image->execute();
$explore_image->store_result();
$explore_image->bind_result($body, $image);
// output data of each row
while ($explore_image->fetch()) {
if($image!=''){
$newImage="<img src='".$image."' id='explore_post_pic'>";
}
else{
$newImage="";
}
echo '<div id="rcorners2">'.$body.'</div>';
echo '<div id="rcorners2">'.$newImage.'</div>';
}
?>
- 2 回答
- 0 关注
- 100 浏览
添加回答
举报