views:

25

answers:

1

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);
+4  A: 

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
$items = mysqli_num_rows($result);I had that, it gives me $items = 1.
Rick Bross
i just edited my post to include my mysqli_query.
Rick Bross
@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
output the amount of rows WHERE userid='$userid' does it just count the primary id, or something?
Rick Bross
oh crap, that is one.
Rick Bross
sorry, pulling from wrong table.Hah.
Rick Bross