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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:40:46+00:00 2026-06-12T17:40:46+00:00

i have pagination system on my echo results however, the page numbers are being

  • 0

i have pagination system on my echo results however, the page numbers are being echo’ed underneath eachother

e.g.

                              1
                2 3 4 5

this is my code:

for($i=0;$i < $count1;$i=$i+$limit)
 {
if($i <> $start)
{       
    echo "<a href='view.php?search=$search&start=$i&limit=$limit&price=$price&category=$category'><font face='Verdana' size='2'><b>&nbsp;$l&nbsp;</b></font></a> ";
}
else
{
    echo "<center><font face='Verdana' size='4' color=#2E9AFE ><b>&nbsp;$l&nbsp;</b></font></center>";
}        

MODIFIED CODE:

$i=0;
 $l=1;
   echo "<p align='left'>";
   for($i=0;$i < $count1;$i=$i+$limit)
   {
  if($i <> $start)
   {        
   echo '<a href="view.php?   search=$search&start=$i&limit=$limit&price=$price&category=$category">$i</a>';
}
else
{
   echo '<span class="current">$i</span>';
}        
$l=$l+1;
  }
 echo "</p>";
  }
  • 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-12T17:40:48+00:00Added an answer on June 12, 2026 at 5:40 pm

    Here is another way of doing the above, with a few added extras:

    $count1 = 10;    
    $menu = '';
    
    $link = array(
      'search' => ( isset($search) ? $search : $search = '' ),
      'start' => ( isset($start) ? $start : $start = 0 ),
      'limit' => ( isset($limit) ? $limit : $limit = 1 ),
      'price' => ( isset($price) ? $price : $price = '' ),
      'category' => ( isset($category) ? $category : $category = '' ),
    );
    
    foreach( range(0, $count1, $limit) as $i ) {
      $menu .= ( ($link['start'] = $i) == $start ? 
        '<span class="current">'.$i.'</span>' :
        '<a href="view.php?'.http_build_query($link).'">'.$i.'</a>'
      ) . PHP_EOL;
    }
    
    echo $menu;
    

    (the above requires php5+)

    With regards to neeko’s comment, to seperate the $start variable from the text displayed in the link – all you have to do is either introduce another variable that counts up with each loop – or, as we already have the key of the range array, we can use that:

    foreach( range(0, $count1, $limit) as $key => $i ) {
      $menu .= ( ($link['start'] = $i) == $start ? 
        '<span class="current">Page'.($key+1).'</span>' :
        '<a href="view.php?'.http_build_query($link).'">Page'.($key+1).'</a>'
      ) . PHP_EOL;
    }
    

    I’ve used $key + 1, because $key will be zero-based (i.e. counting up from Zero) but the +1 just shifts things so we count up from 1 instead.

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

Sidebar

Related Questions

I have a pagination system like this: [content] 1 2 3 Next > when
I have pagination links set-up like this: http://localhost/?page=2 http://localhost/?page=3 They are wrapped in Anchor
Im currently using Code Igniter to have pretty URLs, and I have this system
I have a comment system with pagination, 10 per page. I want to make
I currently have pagination functionality that displays the total page count, but I was
I've have already implemented pagination using the following code: public Paginacao<Anuncio> consultarPaginado(int pagina, Integer
I have an application with associations and will pagination the pages. The index page
So i'm creating a pagination system for a blog-like system. I already have the
I'm trying to make some kind of pagination system. Each page has a maximum
So I've set up a pagination system similar to Twitter's where where 20 results

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.