MySQL Data - Best way to implement paging? -


My iPhone app connects to my PHP web service to get data from MySQL database, a request can return 500 results .

What is the best way to implement paging and retrieve 20 items?

Say I get 20 ads before my database. How can I now request for the next 20 ads?

:

Selection control selection lines returning from the plot statement Can be limited to the number of. LIMIT takes one or two numerical arguments, both of which should be non-integer integer stability (while using the made statements).

With two arguments, the first argument specifies the offset of the first line returning, and the second specifies the number of rows to return. The initial line has offset 0 (not 1):

  SELECT * FROM tbl LIMIT 5,10; Retrieve # Rows 6-15  

To get all the rows from an offset offset by the end of the result set, you can use some larger numbers for the second parameter. This statement receives all the rows from the 96th row to the last:

  SELECT * FROM tbl LIMIT 95,18446744073709551615;  

With one argument, the value specifies the number of rows to return from the beginning of the result set:

  SELECT * FROM tbl LIMIT 5; # Get the first 5 rows  

In other words, the LIMIT line_ count LIMIT is equal to 0, the line_ count.


Comments