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
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 />");
        }
    

Link to comment
Share on other sites

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.