Jump to content

Help with numbering posts


runnerjp

Recommended Posts

At the moment i have added some code to add a number to the post so looks liek this

 

1#

2#

3#

4#

ect

 

The problem is now i have added pagination to it when i go to page 2 it starts form 2# again... any way i can make it carry on from where it left off??

$counter2 = 1;
$counter2++;
echo $counter2;

Link to comment
https://forums.phpfreaks.com/topic/194349-help-with-numbering-posts/
Share on other sites

Sure thing

 

// Find out the total number of pages depending on the limit set
    $numofpages=$rows / $page_rows;
    $totalpages=ceil($numofpages);
    // Start links for pages
    $maxpage   =$totalpages == 0 ? 1 : $totalpages;                   // add this line
    echo "Page " . $pagenum . " of " . $maxpage . "</center>"; // change this



   // Sets link for previous 25 and return to page 1
    
     if ($pagenum != 1)
        {
        $pageprev=($pagenum - 1);
        echo "<center><a href=\"" . $_SERVER['PHP_SELF']
                 . "?page=message&forum=$forum&id=$forumpostid&pagenum=1\"><<</a>  ";
        echo "<a href=\"" . $_SERVER['PHP_SELF']
                 . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pageprev\">PREV </a> ";
        }
    else
        {
        echo "<center>PREV ";
        }
   

    // Loop thru all the pages and echo out the links
    for ($i=1; $i <= $numofpages; $i++)
        {
        if ($i == $pagenum)
            {
            echo "[" . $i . "] ";
            }
        else
            {
            echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
            }
        }

    // Check for straglers after the limit blocks
    if (($rows % $page_rows) != 0)
        {
        if ($i == $pagenum)
            {
            echo "[" . $i . "] ";
            }
        else
            {
            echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=message&forum=$forum&id=$forumpostid&pagenum=$i\">$i</a> ";
            }
        }

     // Print out the Next 25 and Goto Last page links
if (($rows - ($page_rows * $pagenum)) > 0)
        {
        $pagenext=$pagenum++;
        echo "<a href=\"" . $_SERVER['PHP_SELF']
                 . "?page=message&forum=$forum&id=$forumpostid&pagenum=$pagenext\">NEXT </a>  ";
        echo "<a href=\"" . $_SERVER['PHP_SELF']
                 . "?page=message&forum=$forum&id=$forumpostid&pagenum=$totalpages\">>></a>  </center>";
        }
    else
        {
        echo("NEXT </center> <br />");
        }
    

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.