2 回答

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊
刪除$explore_image->store_result
.
并且不要忘記在完成后關(guān)閉準(zhǔn)備好的語句和連接(按此順序)。
根據(jù)您的初始代碼:
$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貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
<?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 關(guān)注
- 131 瀏覽
添加回答
舉報(bào)