REVscene Automotive Forum

REVscene Automotive Forum (https://www.revscene.net/forums/)
-   Computer Tech, Gaming & Electronics (https://www.revscene.net/forums/computer-tech-gaming-electronics_32/)
-   -   PHP Pros... need some help (https://www.revscene.net/forums/656968-php-pros-need-some-help.html)

PornMaster 11-05-2011 12:25 AM

PHP Pros... need some help
 
Well I am trying to get a simple pagination to display all current pages.
The original code displayed
" Prev 1 2 3 ... 100 101 103 Next"

I want it to go like
"Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Next"
Pretty much to show ALL pages

the code is in the spoiler please help
Spoiler!

pokchop 11-05-2011 11:12 AM

I am no PHP pro, but i think you can just replace this whole part with the code i entered underneath.
I could be wrong though, only spend a few minutes looking through it, test it out and let me know if there is a problem :o

Code:

if ($total_pages > (($index*2)+3) && $page >= ($index+3))
{
        $output[] = '<li><a href="'.pag_strip(1, $url).'"' .pag_id(1, $id). '>1</a></li>';
        $output[] = '<li><a href="'.pag_strip(2, $url).'"' .pag_id(2, $id). '>2</a></li>';
}
if ($page > $index+3)
{
        $output[] = '<li><span style="color: #373737;">&nbsp;...&nbsp;</span></li>';
}

for ($i=1; $i<=$total_pages; $i++)
{
        if ($page == $i )
        {
                $output[] = '<li><span class="currentpage">' .$page. '</span></li>';
        } elseif ( ($i >= ($page-$index) && $i < $page) OR ($i <= ($page+$index) && $i > $page) )
        {
                $output[] = '<li><a href="'.pag_strip($i, $url).'"'.pag_id($i, $id).'>'.$i.'</a></li>';
        }
}

if ($page < ($total_pages-6))
{
        $output[] = '<li><span style="color: #373737;">&nbsp;...&nbsp;</span></li>';
}

if ($total_pages > (($index*2)+3) && $page <= $total_pages-($index+3))
{
        $output[] = '<li><a href="'.pag_strip(($total_pages-2), $url).'"'.pag_id(($total_pages-2), $id).'>'.($total_pages-2).'</a></li>';
        $output[] = '<li><a href="'.pag_strip(($total_pages-1), $url).'"'.pag_id(($total_pages-1), $id).'>'.($total_pages-1).'</a></li>';
}

Code:

for ($i=1; $i<=$total_pages; $i++) {
        if ($page == $i )
        {
                $output[] = '<li><span class="currentpage">' .$page. '</span></li>';
        }
        else
        {
                $output[] = '<li><a href="'.pag_strip($i, $url).'"'.pag_id($i, $id).'>'.$i.'</a></li>';
        }
}


PornMaster 11-05-2011 11:42 PM

Got it to work but can't make it go into 2 or 3 different rows to fit on one page

Spoiler!

PornMaster 11-06-2011 12:42 AM

got it changed css file added float: left padding-bottom: 20px


All times are GMT -8. The time now is 05:31 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
SEO by vBSEO ©2011, Crawlability, Inc.
Revscene.net cannot be held accountable for the actions of its members nor does the opinions of the members represent that of Revscene.net