PHP Limit Data Selections In MySQL

In this tutorial, we are going to tackle about PHP Limit Data Selections From MySQL. We have to use a LIMIT function to specify the number of our data to display. You can use this codes if you have a pagination table to have multiple pages to minimize the size of your data table.

We are going to set the LIMIT of our data into 4. This is the code.

  1. <?php
  2. require_once('connection.php');
  3. $result = $conn->prepare("SELECT * FROM tbl_registration ORDER BY tbl_registration_id ASC LIMIT 4");
  4. $result->execute();
  5. for($i=0; $row = $result->fetch(); $i++){
  6. $id=$row['tbl_registration_id'];
  7. ?>

This is the output:

This is our data in the database table. ResultAfter we code the LIMIT function in the SELECT Statements. The output looks like this: Result So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment