title: LIMIT View All Data from Database in Page
body: <p>I'm currently making a student's directory using PHP and MYSQL.<br/>
  However I can't control how many students would register and join the site so I'm having a bit of problem in producing the <em>all_students.php</em> page.</p>
  
  <p>The <em>all_students.php</em> page would get <strong>all users</strong> from the table called <code>students_users</code> in my database. So normally:</p>
  
  <pre><code>$sql = "SELECT * FROM students_users";
  $result = mysqli_query($dbcon,$sql);
  while ($data=mysqli_fetch_assoc($result)) {
      $name = $data['name'];
      $age = $data['age'];
  ...
      echo $name;
      echo $age;
  ...
  </code></pre>
  
  <p>It's currently working however I noticed that the more users I got, the page becomes as longer and becoming a burden for the users because they have to scroll down for example to names that starts with letter "T".</p>
  
  <p>Any ideas how can I divide the users to display to a single page (like the search results on Google where it displays about 10 results and then it has this <code>Page 1 | Page 2 | Page 3 |...</code>?
  <br/><br/>
  I already tried this: <br/>
  <code>"SELECT * FROM students_users Limit 20";</code> <br/>
  and <br/>
  <code>"SELECT * FROM students_users LIMIT 20,20";</code> for the next page and so on
  <br/><br/>
  My only problem is that, I don't know how exactly is my number of users will grow and that for example if I have say: 400 users and I want to divide the <code>all_students.php</code> in to viewing theses users using like 10 Pages - <code>Limit 20</code> will not be enough. I have to use <code>Limit 50</code> or something right?
  <br/><br/>
  How can I make it <strong>automatically divides</strong> <strong>all my users</strong> in to displaying within the <strong>10 Pages</strong> view? <br/><br/>
  Example: <br/>
  10 users - 1 user per page <br/>
  100 users - 10 users per page <br/>
  500 users - 50 users per page<br/>
  etc.
  <br/><br/>
  without having to constantly change the <code>Limit</code> code as my number of users grow?</p>