How can I implement custom pagination in mysql using a query? Based on the page number I need to fetch the records from the database, is it possible? It would be helpful to get some queries for this.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To display your pagination you also need to know the total of rows in order to calculate the number of page links to display like:
Page: 1 2 3 4 5 6 ….
Making a query to MySQL to count the number of rows like “SELECT COUNT(*) …” is not an option, you would lose some of the performance you saved with the “LIMIT” query in the first place. There’s a much more efficient way of doing this, you just need to modify your original query just a little, like:
Immediately after that first query you run: