0

I don't know if i am doing it right, this is what I got:

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

It always sets $items = to 1 for some reason.

Here is my 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);
Rick Bross
  • 1,060
  • 3
  • 16
  • 39

1 Answers1

4

Well, $row only contains one row so....

$items = mysqli_num_rows($result)

should give you the correct number of items


Anyway, why are you doing that in a loop? The number of rows is constant...

nico
  • 50,859
  • 17
  • 87
  • 112
  • $items = mysqli_num_rows($result); I had that, it gives me $items = 1. – Rick Bross Aug 15 '10 at 11:47
  • 1
    @Rick Bross: well, of course it returns 1. I'm assuming the ID is unique for each user, so your query does indeed only return 1 result. What would you expect as result? – nico Aug 15 '10 at 11:51
  • output the amount of rows WHERE userid='$userid' does it just count the primary id, or something? – Rick Bross Aug 15 '10 at 11:52