本文介紹了檢查 mysqli_query 是否返回任何值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有以下代碼,我想知道 mysqli_query
是否返回任何行,如果返回則返回錯誤.
I have the following code and I would like to know if mysqli_query
returned any rows and if so return an error.
$result = mysqli_query($connection, "SELECT * FROM users");
if ($result == "") {
echo "No records found";
} else {
echo "There is at least one record in the database";
}
如果結果返回為空,我就會遇到麻煩.我已經嘗試使用了幾種東西,但如果沒有找到任何東西,我無法弄清楚如何讓它正常工作.
I'm having trouble if the results come back as empty. I've tried using several things and can't figure out how to get it work correctly if nothing is found.
推薦答案
使用 mysqli_num_rows 檢查是否有任何行返回.
Use mysqli_num_rows to check if any rows were returned or not.
這篇關于檢查 mysqli_query 是否返回任何值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!