title: MySQL server not returning correct output
body: <p>I have a table named <code>booktable</code> as shown in screenshot. When I run the query the output is <code>Table availabe</code> though it shoud be <code>Table not available.</code><br> Initially, I tried to check the condition without using <code>array_key_exists</code> and the solutions are mentioned below but none of them worked.</p>
  
  <pre><code>&lt;?php
  require 'dbconnect.php'; //connection to db is success
  
  $search = "SELECT Table_list FROM booktable WHERE status='booked'";
  $table_query = mysqli_query($dbconnect,$search);
  $row_check = mysqli_num_rows($table_query);
  
  if($row_check&gt;=1){
      $tables = array();
      while($row=mysqli_fetch_assoc($table_query)){
          $output = $row['Table_list'].'&lt;br&gt;';
          echo $tables[] = $output;  //returns o/p: Table1, Table2, Table3
          }
      if(array_key_exists('Table1',$tables)){ //trying to check if 'Table1' is in the array
          echo 'Table not available'; //if 'Table1' exists should echo this line
      }else{
          echo'Table available';
      }
  }
  ?&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zk2dc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zk2dc.png" alt="table:booktable"></a></p>
  
  <p>If I put <code>array_key_exists</code> part inside <code>while loop</code> the o/p would be same as not putting the statement inside the loop, i.e there is no change in o/p. <br> so, I tried to go with this approach but I'm not getting right o/p as before. What's wrong with this approach? </p>