title: how to get count(*) the right way in php
body: <p>I tried to <code>count()</code> the data from database with php but it don't show me the total data but it show the datas.</p>
  
  <p>this is how I count</p>
  
  <pre><code>$query = "SELECT 
          mitra.*,         
          user.username, 
          user.privilege, 
          user.name 
      FROM 
          mitra
      INNER JOIN 
          user ON mitra.id_user = user.id "
  
  $result = $connection-&gt;query($query);
  
  if ($result-&gt;num_rows &gt; 0) {
      foreach ($result as $row) :
          $id = "" . $row["id"] . "";
          $total = "" . $row["total_puas"] . "";
          $privilege = "" . $row["privilege"] . "";
  
          if ($privilege == 2) :
              $calculate = $total / count($id);
              var_dump(count($id));
          endif;
      endforeach;
  }
  
  ===================
  =   id =  total   =
  =  1   =   45.84  =
  =  2   =   75.45  =
  =  3   =   34.54  =
  ===================
  </code></pre>
  
  <p>when I var_dumb it it shows <code>int(1)int(1)int(1)</code> not <code>int(3)</code> that what I wanted. </p>
  
  <p>actually I want to count <code>$calculate</code> with the data in <code>$total</code> that should be there is float and the amount from <code>$total</code> that I want to divided with <code>count id</code> </p>
  
  <p>is there any solution that how to count the amount from <code>$total</code> and can be devided with <code>count $id</code> that should be 3?. please help</p>
  
  <p>what I really trying to do from that table example is like <code>45.84 + 75.45 + 34.54 / 3</code></p>