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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:44:27+00:00 2026-06-07T00:44:27+00:00

The query is: SELECT * FROM `news` ORDER BY `id` LIMIT ($curr_page * 5),

  • 0

The query is:

SELECT * FROM `news` ORDER BY `id` LIMIT ($curr_page * 5), ( ($curr_page * 5) + 5 )

Where $curr_page is a php variable which is getting a value from $_GET['page']

I want to make a pagination (5 news on each page), but I don’t know why the mysql is returning me extra values.

On the first page the result ok: $curr_page = 0

The query would be:

SELECT * FROM `news` ORDER BY `id` LIMIT 0, 5

But on the second page, the result from the query is adding extra news, 10 instead of 5.

The query on the second page:

SELECT * FROM `news` ORDER BY `id` LIMIT 5, 10

Whats wrong? Why the result has 10 values instead of 5?

Thank you!

  • 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-07T00:44:29+00:00Added an answer on June 7, 2026 at 12:44 am

    look this example, the first parameter is the row to begin and the second is the number of result to display

    mysql> select * From t1 limit 0,5;
    +----------+------------+--------------+---------------------+
    | actor_id | first_name | last_name    | last_update         |
    +----------+------------+--------------+---------------------+
    |        1 | PENELOPE   | GUINESS      | 2006-02-15 04:34:33 |
    |        2 | NICK       | WAHLBERG     | 2006-02-15 04:34:33 |
    |        3 | ED         | CHASE        | 2006-02-15 04:34:33 |
    |        4 | JENNIFER   | DAVIS        | 2006-02-15 04:34:33 |
    |        5 | JOHNNY     | LOLLOBRIGIDA | 2006-02-15 04:34:33 |
    +----------+------------+--------------+---------------------+
    5 rows in set (0.00 sec)
    
    mysql> select * From t1 limit 5,5;
    +----------+------------+-----------+---------------------+
    | actor_id | first_name | last_name | last_update         |
    +----------+------------+-----------+---------------------+
    |        6 | BETTE      | NICHOLSON | 2006-02-15 04:34:33 |
    |        7 | GRACE      | MOSTEL    | 2006-02-15 04:34:33 |
    |        8 | MATTHEW    | JOHANSSON | 2006-02-15 04:34:33 |
    |        9 | JOE        | SWANK     | 2006-02-15 04:34:33 |
    |       10 | CHRISTIAN  | GABLE     | 2006-02-15 04:34:33 |
    +----------+------------+-----------+---------------------+
    5 rows in set (0.00 sec)
    
    mysql> select * From t1 limit 10,5;
    +----------+------------+-----------+---------------------+
    | actor_id | first_name | last_name | last_update         |
    +----------+------------+-----------+---------------------+
    |       11 | ZERO       | CAGE      | 2006-02-15 04:34:33 |
    |       12 | KARL       | BERRY     | 2006-02-15 04:34:33 |
    |       13 | UMA        | WOOD      | 2006-02-15 04:34:33 |
    |       14 | VIVIEN     | BERGEN    | 2006-02-15 04:34:33 |
    |       15 | CUBA       | OLIVIER   | 2006-02-15 04:34:33 |
    +----------+------------+-----------+---------------------+
    5 rows in set (0.00 sec)
    

    in your case the second parameter is static and the first parameter ($curr_page * 5)

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

Sidebar

Related Questions

$sql = SELECT * FROM news ORDER BY `news_id` DESC LIMIT 1; $result =
I have this PHP code : $query = SELECT * FROM news WHERE news_active
$query = mysql_query('SELECT * from rbf_edades_news order by month DESC '.$limit.''); month and day
I have a mysql query Select * from tbl_schoolphotos where Filename like 'glasshouse_1_%' order
Check this code: $select = mysql_query(SELECT * FROM nieuws ORDER BY id DESC LIMIT
I am trying to do a mysql query to select some news stories from
I have a website under construction, using PHP MYSQL, which contains a news page
I am running this query, $this->db->select('news.news_id, news.title, news.article, news.date_posted, news_assets.news_assets_id, news_assets.url') ->from('news_assets') ->join('news', 'news_assets.news_news_id
this query SELECT * FROM tblContracts LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id INNER
this is the mysql query SELECT * FROM users AS up JOIN users AS

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.