PHP Limit Data Selections In MySQL

Submitted by: 
Language: 
Visitors have accessed this post 1517 times.

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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.