-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!

Greetings and Thank You!

Qirel
  • 23,315
  • 7
  • 41
  • 57
Jan
  • 257
  • 1
  • 5
  • 13

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
  • 680
  • 5
  • 19