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 8932047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:15:12+00:00 2026-06-15T09:15:12+00:00

So I have a table with 45 records (but can be dynamic) and I

  • 0

So I have a table with 45 records (but can be dynamic) and I use mysql_fetch_array() to get the data from the database. What is the best way to output 5 records at a time? So I need to do record 1-5, then have a link for records 6-10, 11-15, and so on. I thought about doing something with array_chunk but not sure how to keep track of the record number. Thanks for hints.

  • 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-15T09:15:13+00:00Added an answer on June 15, 2026 at 9:15 am

    To get the first 5 results form a table:

        SELECT * FROM table ORDER BY  table.column_name ASC  LIMIT 0, 5
        

    • Selects from `table`
    • Ordered by the column name Ascending
    • Limit 0,5 selects the first 5 results, starting at 0.

    Change LIMIT 0,5 to 5,5 to list results 6-10 (start at record 5, and continue for 5 records.)

    Ordering is just good practice to ensure consistency. Under most circumstances set this to ‘id’ if you have an auto-increment ‘id’ column. If you want results sorted by date, order by a timestamp column. If you want data reversed, order by DESC.

    You can keep track of where your queries are though PHP Sessions, Passing GET parameters, temporary database tables, and probably a few more I missed.

    Other solution:

    Use the array returned from the mysql_fetch_array() and utilite http://php.net/manual/en/language.types.array.php

    The obvious disadvantage to this approach is the fact that it fetches all rows in the table. This is okay if you’ll NEVER have more than a manageable number of rows. In your case, 45 should be fine, assuming they’re not gigantic rows. This approach may also may useful if you want data pre-loaded.

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

Sidebar

Related Questions

I have table with 300 000 records (MyISAM). I get record from this table
I have table a joining table b, I only want the records from table
I have this scenario... 1.- I'm providing a Dynamic Table for wich users can
Situation: In my database I have a table in which records may reference other
I have this table with which I create dynamic checkboxes (the number of records
I have following Table with records for ActivityLog: ID, UserId, Category, Created 1 11
I have in my table records that are related one to another by a
i have two table. Records and Villas Records table : ID, VID (Villa ID),
I have a table that has records with a structure similar to this.. ID
I have a innoDB table which records online users. It gets updated on every

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.