0

我不知道我是否做得对,这就是我得到的:

while($row = mysqli_fetch_assoc($result)) {
     $items = mysqli_num_rows($row); 
}

由于某种原因,它总是将 $items = 设置为 1。

这是我的mysqli_query ...

$top10_query = "SELECT * FROM users WHERE userid='$userid'";
                        $result = mysqli_query($cxn, $top10_query) or die("Couldn't execute query.");
                        $row = mysqli_fetch_assoc($result);
4

1 回答 1

4

好吧,$row只包含一行,所以....

$items = mysqli_num_rows($result)

应该给你正确的项目数量


无论如何,你为什么要在循环中这样做?行数是恒定的...

于 2010-08-15T11:43:41.007 回答