title: Using database count rather than counting results in PHP mysqli
body: <p>How to convert to use a database count?</p>
  
  <pre><code>function get_orders_count(){                                                                    
    global $mysqli;                                                                        
    $query ='                                                                                      
      SELECT                                                                                 
        a.order_id                                                                     
      FROM                                                                                   
        assignments a                                                                  
      WHERE                                                                                  
        client_id = '.$_SESSION['user']['ID'];                                         
    $result = $mysqli-&gt;query($query);                                                              
    return $result-&gt;num_rows;                                                                      
  }
  </code></pre>