Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在没有 mysql_num_rows 的情况下计算数据库中的帖子数?
我正在使用这个:
$post_query = mysql_query("SELECT * FROM posts WHERE user='$user'"); $number = mysql_num_rows($post_query);
但是即使有 0 个帖子,mysql_num_rows 也总是返回 1?我需要在有 0 个帖子时返回 0 的东西。
SELECT count (*) FROM posts WHERE user='$user'
SELECT count(*) FROM posts WHERE user='$user'
Read up on your sql first 2 seconds searching on google would have given you the answer