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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:26:52+00:00 2026-06-10T20:26:52+00:00

I work on a page(.php) that show some information from databases(like article name,article author).I

  • 0

I work on a page(.php) that show some information from databases(like article name,article author).I also have a pagination script that work good(the ideea of pagination script is when I press a link the url of the site goes to something like ?page=2)Now I try to numbering the records that I show form databases.But how can I do that?

Pagination script:

$per_pages = 6;
$nrofarticles_query = mysql_query("SELECT COUNT('id') FROM tbl_articles");
$nrdearticole = mysql_result($nrofarticles_query, 0);
$totalpages = ceil($nrdearticole/$per_pages);
$currentpagedisplay = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$firstpair = ($currentpagedisplay - 1) * $per_pages;

I echo record from database like so:

$articles_set = mysql_query("SELECT * FROM tbl_articles LIMIT $firstpair, $per_pages");
while($article = mysql_fetch_array(article_set)){
     echo $article['article_name'];
}

So I show 6 records from database on page change show the next 6 records or if is less than 6 show how many remained .How can I numbering the records like this:

?page=1
1 article_name1
2 article_name2
3 article_name3
....
6 article_name6

?page=2
keep going
7 article_name7
8 article_name8
.....

EDIT

I was thinking to something like

    <?php
    $nrofarticles = 0;
    $articles_set = mysql_query("SELECT * FROM tbl_articles LIMIT $firstpair,$per_pages");
    confirm($articles_set);
    while($article = mysql_fetch_array($articles_set)){
        $nrofarticles ++;
    }
    echo "<ul id=\"id\">";
        for($i = $firstpair+1; $i<=$nrofarticles * $currentpagedisplay; $i++){
                echo '<li class="nr_id">' .$i. '<sub>#</sub></li>';
        }
    echo "</ul>";
?>

It’s works but only on first 2 page of 3 because I have 16 articles in total – so on last page $firstpair + 1 will be 13 and $nrofarticles * $currentpagedisplay will be 12(4(articles) * 3(page=3)).

  • 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-10T20:26:54+00:00Added an answer on June 10, 2026 at 8:26 pm

    Go use a framework. You’ll get pagination (and all sorts of extras) for free.

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

Sidebar

Related Questions

I have written a simple code in page test_cookie.php to work with cookies. if(isset($_GET['data']))
Like many variables in PHP using ini_set() on a page doesn't actually work. I've
I have a work page that shows all projects. I am using a taxonomy
I have this code to show me some web page into my domain (in
I have a page like for example: http://www.stackoverflow.com/how-many-users-visited I have inside that page already
now I can make it work with user-profile.tpl.php page,all this page does is to
http://steph.net23.net/work.php here is my test link. This page has a jquery script in it
I'm trying to create a large, multi-page, PHP web application for work where a
I have an iframe which does some server-side work and displays an image. We
I have a specific case here in which I would like some security advice.

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.