PHP - SPLessons

PHP Limit Data Selections From MySQL

Chapter 40

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PHP Limit Data Selections From MySQL

PHP Limit Data Selections From MySQL

shape Description

To display certain list of records from the database, put the list of records to display using the LIMIT. It specifies the number of records which wanted to select form the table.

shape Example

$sql = “SELECT * FROM Orders LIMIT 100”;

Here 100 records are selected from the table to display.

Suppose there are 30 to 60 records. To start displaying records form 30,use OFFSET Statement. Below example explains about it.

$sql = “SELECT * FROM Orders LIMIT 30 OFFSET 29”;

Summary

shape Key Points

  • To display only selected records the LIMIT statement is used.
  • To display the records in a certain range, OFFSET is used.