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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:32:49+00:00 2026-05-20T10:32:49+00:00

So, i have this database right, with some fields called ‘id’, ‘title’ and ‘message’.

  • 0

So, i have this database right, with some fields called ‘id’, ‘title’ and ‘message’. Now i got like 700 messages in the database. So all i wanna do, is set a limit of max 50 message title’s per page, and make multiple pages… How can i do that?

I only know to get the first page, using LIMIT…

  • 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-05-20T10:32:50+00:00Added an answer on May 20, 2026 at 10:32 am

    As you guessed, you have to use the LIMIT keyword.

    It accepts two value (quoting) :

    • the offset of the first row to return
    • the maximum number of rows to return

    In your case, you’ll have to use something like this for the first page :

    select * from your_table order by ... limit 0, 50
    

    And, then, for the second page :

    select * from your_table order by ... limit 50, 50
    

    And for the third one :

    select * from your_table order by ... limit 100, 50
    

    And so on 😉

    Edit after the comment : to get the page number, you’ll have to receive it from your URLs, that would look like this :

    http://www.example.com/page.php?pagenum=2
    

    Then, you’ll calculate the first value for the limit, :

    $offset = 50 * intval($_GET['pagenum']);
    

    And inject it in your query :

    select * from your_table order by ... limit $offset, 50
    

    Constructing URLs to the differents pages is now a matter of getting URLs such as these :

    http://www.example.com/page.php?pagenum=0
    http://www.example.com/page.php?pagenum=1
    http://www.example.com/page.php?pagenum=2
    ...
    

    If you know you have 700 elements, and 50 per page, you’ll have 700/50 pages 😉

    So, something like this should do the trick :

    for ($i=0 ; $i<700/50 ; i++) {
        // Use http://www.example.com/page.php?pagenum=$i as URL
    }
    

    Of course, 700 is a value that can probably change, and should not be hard-coded : it should be determined from the database, using a count query :

    select count(*) as total
    from your_table
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In mysql database i have this column called: Name: Date Type: datetime I have
I have this algorithm in Java to store passwords in database. I'd like to
I have a database with a single table right now, which contains the following
I have this legacy database for which I'm building a custom viewer using Linq
I have this scenario where I need data integrity in the physical database. For
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have this question in which I have a SQL Server Compact Edition database
I have a database on a SQL Server 2000 server. This database has a
I have a production database where usage statistics reside. This database is responsible for
I have a requirement to implement contact database. This contact database is special in

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.