title: Check if mysqli_query is empty
body: <p>I'm looking for a way to check if my mysqli_query result is empty.</p>
  
  <p>My code:</p>
  
  <pre><code>$result = mysqli_query($con, "SELECT ......");
  </code></pre>
  
  <p>Then there is the table head:</p>
  
  <pre><code>&lt;table class="table table-striped" width="100%"&gt;
  &lt;thead&gt;
  &lt;table class="table table-striped" width="100%"&gt;
          &lt;thead&gt;
              &lt;th&gt;Jahr&lt;/th&gt;
  </code></pre>
  
  <p>And then I generate the rows with a while loop:</p>
  
  <pre><code>while($ausgabe = mysqli_fetch_object($result)){ ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $ausgabe-&gt;jahr; ?&gt;&lt;/td&gt;
  </code></pre>
  
  <p>And now I want to make an if query to check if I have to display the table, before the table begins, something like this:</p>
  
  <pre><code>if($result){    
  &lt;table class="table table-striped" width="100%"&gt;
          &lt;thead&gt;
              &lt;th&gt;Jahr&lt;/th&gt;
  </code></pre>
  
  <p>But this does not work, it only works with asking if mysqli_fetch_object is empty but this code is below my table head so I can't use this.</p>
  
  <p>Do you have any ideas?</p>