使用PHP [SQL]显示SQL数据库中的有限行

This question already has an answer here:

Consider a database table with 100 rows and the table is updated ie the number of rows increases on a regular basis.

Suppose that when a visitor visits my website, my table consist Xrows, but I want only rows from (X-25) to (X-50) to be visible.

I need help to code a PHP such that only rows from (X-25) to (X-50) are visible

I am new to PHP ,SQL a help would aid me a lot :)

</div>

To get last 20 records you have inserted.. if you are using auto increment primary key orderid,you can use the query

"SELECT * FROM Orders ORDER BY orderid DESC LIMIT 20"; 

You can use limit to show particular record.

The SQL query below says "return only 10 records, start on record 15":

 "SELECT * FROM Orders LIMIT 15, 10";

1) Consider, you have 100 records 0-99. Ad you want to display 20 records starting from 11th record then query will be

"SELECT * FROM Orders LIMIT 11, 20";

2) If you want to display 1st 20 records then query will be :

 "SELECT * FROM Orders LIMIT 20";

3) If you want to display latest 20 records then :

 "SELECT * FROM Orders ORDER BY orderid DESC LIMIT 20"; 

In MYSQl

SELECT * FROM table LIMIT 25, 25 -- get 25 records after row 26

If you want row 25-50 in descending order you can do this by :

SELECT * FROM (SELECT * FROM ORDERS LIMIT 25, 25) ORDER BY id DESC