我試圖顯示搜索後在數據庫中找到的行數。獲取PDO執行後的行數
這裏是我的代碼:
$city = $_POST['city'];
$bloodType = $_POST['donorType'];
$q = $db->prepare("SELECT count(*) FROM `users` AS numusers WHERE `city` = :city AND `bloodType` = :bloodType");
$q->bindValue(":city",$city,PDO::PARAM_INT);
$q->bindValue(":bloodType",$bloodType);
$q->execute();
while($row = $q->fetch(PDO::FETCH_ASSOC)){
echo "<p align='center'><h5> There is/are <span class='red-text'>".$row['numusers']."</span> available donor(s) found.
You must be a <b><a href='register.php'>registered user</a></b> to view their details.</h5></p>";
}
這是最後一次嘗試我做到了。並且我收到此錯誤消息 `注意:未定義索引:numusers
如何解決提示?
它應該像這樣SELECT count(*)as numusers – Indrajit