我试图找到我给定数组中的数组总数。 我已经尝试过使用count()函数和sizeof()函数,但是当我知道只有5个时我们都说有66666个数组(我认为这是因为它在while循环中)。
$result = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_assoc($result)) { echo count($row); }I am trying to find the total number of arrays in my given array. I have tried using the count() function and the sizeof() function but both say that there are 66666 arrays when I know there are only 5 (I think this is because it is in a while loop).
$result = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_assoc($result)) { echo count($row); }最满意答案
我想你正在寻找这个功能
mysql_num_rows - 获取结果中的行数
文档: http : //www.php.net/manual/en/function.mysql-num-rows.php
正如其他人建议的那样,我至少会研究mysqli或者最好是PDO而不仅仅是mysql。
I think you are looking for this funciton
mysql_num_rows — Get number of rows in result
documentation: http://www.php.net/manual/en/function.mysql-num-rows.php
As others suggested I would look into at least the mysqli or preferably PDO instead of just mysql.
更多推荐
发布评论