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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:59:46+00:00 2026-06-07T12:59:46+00:00

I have a simple navigation php script which works ok. The only problem is

  • 0

I have a simple navigation php script which works ok.
The only problem is that I need to find a way to display the pagination links on top of the page instead of the bottom.
So for me a newb, it seems impossible since I have to show the pagination links before the actual navigation variables are being declared.

Can this be done?

Here is the script:

<?
$numrows = '600';
$rowsperpage = 20;
$totalpages = ceil($numrows / $rowsperpage); 
if ($currentpage > $totalpages){ $currentpage = $totalpages; } 
if ($currentpage < 1){ $currentpage = 1; } 
$offset = ($currentpage - 1) * $rowsperpage; 

HERE I query the data from the table and basically fill in the page.

Now starts the pagination links:

$range = 3;
if ($currentpage > 1) {  
    echo '<a href="'.$site_current.'/'.$slug.'/">First</a>'; 
}
$prevpage = $currentpage - 1;   

echo '<a href="'.$site_current.'/'.$slug.'/'.$prevpage.'/">Previous</a>';

for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {   
    if (($x > 0) && ($x <= $totalpages)) {      
        if($x == $currentpage){ 
            echo '<span class="current">'.$x.'</span>'; 
        } else { 

            echo '<a href="'.$site_current.'/'.$slug.'/'.$x.'/">'.$x.'</a>';

        } 
    } 
}

if ($currentpage != $totalpages){  
    $nextpage = $currentpage + 1;    
    echo '<a href="'.$site_current.'/'.$slug.'/'.$nextpage.'/">Next</a>';   
    echo '<a href="'.$site_current.'/'.$slug.'/'.$totalpages.'/">Last</a>'; 
}
?>
  • 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-07T12:59:48+00:00Added an answer on June 7, 2026 at 12:59 pm

    When I do anything in PHP I do the following

    <?php
        //Calculate anything I need for the page to be displayed
    
        //Build the html page and fill in variables where needed
    ?>
    

    You may also want to look into frameworks like smarty that separate the logic from the template designs. PHP is really a templating language in itself but I actually quite like using smarty.

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

Sidebar

Related Questions

I recently made this simple navigation where you have a couple links that have
I have simple php validation form that is halfway working. If you leave the
I have a site that has a scrolling navigation bar. I need to save
i have a site with a simple PHP-Navigation (using $_GET-Variables). HTML-code for navigation links
I have a simple PHP class, I'm trying to access a property of that
My problem is as follows: I have a simple navigation <ul class=navigation> <li class=heading
I have a simple UL navigation menu with width of 1000px: <ul class=menu> <li
I want to create some simple navigation in sencha touch 2. I have questions
I have implemented my own simple version of a navigation window, mainly because navigation
I have an app i building which is a simple naviagtion app. I do

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.