title: Count Total Record in Database for Limit
body: <p>I just wanna show 20% users from total users in my database. This is my code in PHP, but I'm using limit 3 for showing users. But how if I wanna show 20% from total users? It means I have to count all rows in my field and multiply it with 0.2. But it doesn't work. So this is my begining code that I don't change it yet.  </p>
  
  <pre><code>&lt;table class="table table-striped table-hover "&gt;
        &lt;thead&gt;
          &lt;tr&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
        &lt;?php
  
        function getName($id){
          $d=mysql_fetch_array(mysql_query("SELECT * FROM infouser WHERE ID_User='$id' "));   
          return $d['fullname'];
      } 
  
  
      $sqlx= mysql_query("SELECT * FROM correlation WHERE ID_User = '".$_SESSION['iduser']."' ORDER BY result DESC limit 3");
      $i=0;
      while(
          $datax=mysql_fetch_array($sqlx))
          {       
          $i++;
      $ID_User=$data['ID_User'];
      $u[$i]=$ID_User;
      ?&gt;
  
  
          &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $i?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;?php echo getName($datax['ID_User_Recommendation'])?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;a href= "test.php?page_owner=&lt;?PHP echo base64_encode(strip_tags($datax['ID_User_Recommendation']));?&gt;" &gt;View Profile&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;?php    }
      ?&gt;
        &lt;/tbody&gt;
      &lt;/table&gt; 
  </code></pre>
  
  <p>I've edited my last post, to make it clearly. Because I've trying with the answer but still stuck and doesn't work. So here, I give my code that I don't change. Please help, because it's not simple as I think. Thank you in advance anyway. <strong>Btw, that file I included to another file, which that another file is already included with file for connection to database.</strong></p>