Jump to content

[SOLVED] Pagination-- Please help!


jlp09550

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.