Jump to content

Recommended Posts

Hello there.

 

I just came across a pagination script here.. but it stopped working.. I need some help.

 

$total_pages = $post_count%10;
for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i "; 
        } else { 
            echo "<a href='" . $PHP_SELF . "?page=$i'>$i</a> "; 
    } 
} 

 

$total_pages = 0 .. at the moment.. since $post_count divided by 10 equals 0.

 

Thanks..

Link to comment
https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/
Share on other sites

Shouldn't it be

$total_pages = ($post_count / 10);

?

 

I had tried that.. but when the post count equals zero, it messed up the pages.

Your suggestion helped a bit.. but.. like I just said.. yeah.

 

(I had a pagination script a long time ago, but lost it.. although it worked perfectly >_<)

try

 

$total_pages = $post_count/10;
for($i = 1; $i <= $total_pages; $i++){ 
    if($_GET['page'] == $i){ 
        echo $i.' '; 
        } else { 
            echo '<a href="' . $_SERVER['PHP_SELF'] . '?page='.$i.'">'.$i.'</a> '; 
    } 
} 

 

not sure if it works... i wrote it in a hurry but it should be okey

try

 

$total_pages = $post_count/10;
for($i = 1; $i <= $total_pages; $i++){ 
    if($_GET['page'] == $i){ 
        echo $i.' '; 
        } else { 
            echo '<a href="' . $_SERVER['PHP_SELF'] . '?page='.$i.'">'.$i.'</a> '; 
    } 
} 

 

not sure if it works... i wrote it in a hurry but it should be okey

 

Nope, doesn't help.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.