php - fetching all entries from database under a condition -


i fetching rows database when status 1.

it isn't working properly. if first entry status equal 1, fetch data database when statuses not 1. , if first entry status not 1 rest are, not fetch.

$status = $mysqli->query("select status overrides professor = '$name'")->fetch_object()->status;  

then code wish restrict status 1 put under:

if ($status == 1) { 

is should add above code?

i can't understand, but:

  • put results in array , iterate , need.
  • or 2 or 3 querys.
  • or iterate results in while fetch , break if first not condition.

if use mysqli, can use prepared statement prevent injection "'$name'" dangerous , ugly.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -