-2

I want to get some values from my MySQL database. I send a request and get the data back. Then I say: $value->fetch_assoc(). My question now is, how can I check if I got 0 Rows back or at least more than 0?

Is that right?:

if($row = $value->fetch_assoc() > 0){...}

If not, how can I check that? And I'am forced to use >= 0 or is just >0 ok? - I want only to enter the if if I got more than 0 (1 or bigger) back!

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jan
  • 277
  • 1
  • 6
  • 16

1 Answers1

1

You could check by using the variable num_rows of a query result:

if($value->num_rows > 0) {...}

Have a nice day

Ad5001
  • 748
  • 5
  • 19