Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:24:58+00:00 2026-06-14T10:24:58+00:00

I am using PHP while() to fetch the results of a database query. while($results

  • 0

I am using PHP while() to fetch the results of a database query.

while($results = mysql_fetch_array( $galleryresult )) { // show the results };

However, I would like to paginate the results if they exceed a certain number of entries. So for example if there are more than 12 entries returned, only the first 12 will be shown.

1) How can I adapt while() so only the first 12 entries are returned on the first page.

2) Then how can I adapt while() so the 13th-24th result are returned on the second page and so on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:24:59+00:00Added an answer on June 14, 2026 at 10:24 am

    Modify the query such that only 12 entries are in the result set. That way you do not need to modify the while loop.

    Add a parameter to the URL, that tells the script the offset that should be used in the SQL query.

    Create a query that counts the total number of results. Use this to determine how many pages should be displayed in the pager.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using php query to retrieve information from a mysql database with mysql_fetch_array
Using PHP I would like to be able to list root's crontab. I am
i created a simple search engine that displays mysql database results using the php
The goal: Connect to database using php to extract results Loop through results Store
I am using PHP to query a MYSQL database, and I am trying to
I am using a PHP while loop in order to get data from a
After using PHP for a while now, I've noticed that not all built-in PHP
I am experiencing a fatal error while using artisan on the (fantastic) Laravel PHP
Using PHP I echo out table rows in a loop like this: <?php /*
I am trying to retrieve values from the database using mysql and PHP. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.