我怎樣才能dispaly「無項目」時,數據庫沒有values.here是我的代碼,我應該在哪裏需要把else{ echo 'No item';}
如何識別mysqli_stmt_fetch返回0
if ($stmt = mysqli_prepare($link, "SELECT id,name,price,image FROM product Limit ?,8")) {
mysqli_stmt_bind_param($stmt, "s", $page_1);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$ids,$title,$prc,$image);
while (mysqli_stmt_fetch($stmt)) {
$id = $ids;
$pst_title = $title;
$price = $prc;
$pst_image = $image;
$price = number_format($price, 2);
echo ' <article>';
echo " <img src='admin/gem/$pst_image' alt='images'></td>";
echo " <h3>$pst_title</h3>";
echo " <h4>$.$price</h4>";
echo " <a href='gem.php?id={$id}' class='btn-add'>View more</a>";
echo ' </article>';
}
}
可以設置一個計數器在while語句還是有PDO中的'num_results'樣式元素? 'if($ stmt-> fetchColumn()> 0)'或類似的東西? – Twisty