Jump to content

Pagnation help


darkfreaks

Recommended Posts

ok my pagnation wont go onto page 2 itj ust shows up  blank any thoughts ???

 

 <?php
 echo"<p align='right'>";
function paginate($last, $page, $href, $max_results=25) 
{ 
    $span = $max_results-2; // Remove the first & last pages from display... 
    $pad = floor(($span-1)/2); // Round down to make this "symmetrical" 

    // No matter what, we'll show the Previous & first page link: 
    if($$page > 1) 
        $content = '<a href="' . $href . '?page=' . ($page-1) . '">« Previous</a>'; 
    else 
        $content = '« Previous'; 

    if($current == 1) 
        $content .= ' <a href="' . $href . '?page=1" class="page">1</a>'; 
    else 
        $content .= ' <a href="' . $href . '?page=1" class="">1</a>'; 

    # If the current page is in the first part 
    if($page >= 1 && $page <= $max_results) 
    { 
        for($i=2; $i<=$span+1; $i++) 
        { 
            $class = ($page == $i) ? 'page' : ''; 

            $content .= ' <a href="' . $href . '?page=' . $i . '" class="' . $class . '">' . $i . '</a>'; 
        } 

        // Ellipsis between span and last number.  i.e.: 15 ... 25 Next 
        $content .= ' ...'; 
    } 
    # If the current page is in the last part of the links 
    elseif($page <= $last && $page >= $last-($max_results-1)) 
    { 
        // Ellipsis between 1 and next number.  i.e.: 1 ... 10 
        $content .= ' ...'; 

        for($i=($last-$span); $i<$last; $i++) 
        { 
            $class = ($page == $i) ? 'page' : ''; 

            $content .= ' <a href="' . $href . '?page=' . $i . '" class="' . $class . '">' . $i . '</a>'; 
        } 
    } 
    # Otherwise, just show the parts we need... 
    else 
    { 
        // Ellipsis between 1 and next number.  i.e.: 1 ... 10 
        $content .= ' ...'; 

        for($i=($page-$pad); $i<=($page+$pad); $i++) 
        { 
            $class = ($page == $i) ? 'page' : ''; 

            $content .= ' <a href="' . $href . '?page=' . $i . '" class="' . $class . '">' . $i . '</a>'; 
        } 
         
        // Ellipsis between span and last number.  i.e.: 15 ... 25 Next 
        $content .= ' ...'; 
    } 

    // Show the last page... 
    if($last == $page) 
        $content .= ' <a href="' . $href . '?page=' . $last . '" class="page">' . $last . '</a>'; 
    else 
        $content .= ' <a href="' . $href . '?page=' . $last . '">' . $last . '</a>'; 

    // Show the Next link... 
    if($current < $last) 
        $content .= ' <a href="' . $href . '?page=' . ($page+1) . '">Next »</a>'; 
    else 
        $content .= ' Next »'; 

    // Return the link stuff... 
    return $content; 
} 

echo 'Current Page: 1 :: ' . paginate(25, 1, $_SERVER['PHP_SELF'], 11); 
echo '<br /><br />'; ?>

Link to comment
https://forums.phpfreaks.com/topic/91423-pagnation-help/
Share on other sites

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.