phppaginationnested

PHP Nested Pagination / Paging


let's straight to the point...

for example, I have Country and City database like this :

+---------------+------------------+

|CountryName |CityName |

+---------------+------------------+

| US | Washington |

| US | Chicago |

| US | Miami |

<--- until 100 rows for US --->

| UK | London |

| UK | Chelsea |

| UK | Tottenham |

<--- until 100 rows for UK --->

<--- there are 200+ country name --->

and here's what I want to do with PHP :

Country Name : US

-------- >> LIMIT 10 City Only ------>> SEE PAGE 2 TO SEE MORE

Country Name : UK

-------- >> LIMIT 10 City Only ------>> SEE PAGE 2 TO SEE MORE

-------- >> LIMIT 10 COUNTRY Only ------>> SEE PAGE 2 TO SEE MORE

can it be done with PHP? How to do multiple / nested Pagination like this? thanks.


Solution

  • SELECT * FROM MyTable WHERE CountryName = "US" LIMIT $per_page, $start
    

    Where $per_page is the ammount of entries per page, in this case, 10

    $start is where it starts, normally (page number - 1 * $per_page)