Jump to content

Syntax error help


n1kko

Recommended Posts

More of the code

 

 $disppages = intval( $total_pages / $nresults );
    if ( $total_pages % $nresults )
    {
        ++$disppages;
    }
    if ( $nresults <= $position )
    {
        $current_page_num = $position / $nresults + 1;
    }
    else
    {
        $current_page_num = 1;
    }
    $limit = $nresults;
    $stages = 3;
    $position = $position;
    $page = $position / $nresults + 1;
    if ( $page )
    {
        $start = ( $page - 1 ) * $limit;
    }
    else
    {
        $start = 0;
    }
    if ( $page == 0 )
    {
        $page = 1;
    }
    $prev = $page - 1;
    $next = $page + 1;
    $lastpage = ceil( $total_pages / $limit );
    $LastPagem1 = $lastpage - 1;
    $paginglinks = "";
    if ( 1 < $lastpage )
    {
        if ( 1 < $page )
        {
            $prevoffset = $position - $nresults;
            $paginate .= "<a href=\"".$scriptis."?position={$prevoffset}&nresults={$nresults}{$extras}\">« Prev</a>";
        }
        else
        {
            $paginate .= "<span class='pagination-disabled'>« Prev</span>";
        }
        if ( $lastpage < 7 + $stages * 2 )
        {
            $counter = 1;
            for ( ; do 
{
$counter <= $lastpage; ++$counter )
                {
                    $newoffset = $counter * $limit - $limit;
                    if ( $counter == $page )
                    {
                        $paginglinks .= "<span class=\"pagination-current\">".$counter."</span>";
                    }
                    else
                    {
                        $paginglinks .= "<a href=\"".$scriptis."?position={$newoffset}&nresults={$nresults}{$extras}\">{$counter}</a>";
                    }
                    break;
                }
            } while ( 1 );
        }
        else if ( 5 + $stages * 2 < $lastpage )
        {
            if ( $page < 1 + $stages * 2 )
            {
                $counter = 1;
                for ( ; $counter < 4 + $stages * 2; ++$counter )
                {
                    $newoffset = $counter * $limit - $limit;
                    if ( $counter == $page )
                    {
                        $paginglinks .= "<span class=\"pagination-current\">".$counter."</span>";
                    }
                    else
                    {
                        $paginglinks .= "<a href=\"".$scriptis."?position={$newoffset}&nresults={$nresults}{$extras}\">{$counter}</a>";
                    }
                }
                $paginglinks .= "...";
                $newoffsetlm1 = $LastPagem1 * $limit - $limit;
                $newoffsetlp = $lastpage * $limit - $limit;
                $paginglinks .= "<a href=\"".$scriptis."?position={$newoffsetlm1}&nresults={$nresults}{$extras}\">{$LastPagem1}</a>";
                $paginglinks .= "<a href=\"".$scriptis."?position={$newoffsetlp}&nresults={$nresults}{$extras}\">{$lastpage}</a>";
            }
            else if ( $page < $lastpage - $stages * 2 && $stages * 2 < $page )
            {
                $paginglinks .= "<a href=\"".$scriptis."?position=0&nresults={$nresults}{$extras}\">1</a>";
                $paginglinks .= "<a href=\"".$scriptis."?position={$limit}&nresults={$nresults}{$extras}\">2</a>";
                $paginglinks .= "...";
                $counter = $page - $stages;
                for ( ; $counter <= $page + $stages; ++$counter )
                {
                    $newoffset = $counter * $limit - $limit;
                    if ( $counter == $page )
                    {
                        $paginglinks .= "<span class=\"pagination-current\">".$counter."</span>";
                    }
                    else
                    {
                        $paginglinks .= "<a href=\"".$scriptis."?position={$newoffset}&nresults={$nresults}{$extras}\">{$counter}</a>";
                    }
                }
                $paginglinks .= "...";
                $newoffsetlm1 = $LastPagem1 * $limit - $limit;
                $newoffsetlp = $lastpage * $limit - $limit;
                $paginglinks .= "<a href=\"".$scriptis."?position={$newoffsetlm1}&nresults={$nresults}{$extras}\">{$LastPagem1}</a>";
                $paginglinks .= "<a href=\"".$scriptis."?position={$newoffsetlp}&nresults={$nresults}{$extras}\">{$lastpage}</a>";
            }
            else
            {
                $paginglinks .= "<a href=\"".$scriptis."?position=0&nresults={$nresults}{$extras}\">1</a>";
                $paginglinks .= "<a href=\"".$scriptis."?position={$limit}&nresults={$nresults}{$extras}\">2</a>";
                $paginglinks .= "...";
                $counter = $lastpage - ( 2 + $stages * 2 );
                for ( ; $counter <= $lastpage; ++$counter )
                {
                    $newoffset = $counter * $limit - $limit;
                    if ( $counter == $page )
                    {
                        $paginglinks .= "<span class=\"pagination-current\">".$counter."</span>";
                    }
                    else
                    {
                        $paginglinks .= "<a href=\"".$scriptis."?position={$newoffset}&nresults={$nresults}{$extras}\">{$counter}</a>";
                    }
                }
            }
        }
        $paginate .= $paginglinks;
        if ( $page < $counter - 1 )
        {
            $newoffset = $position + $nresults;
            $paginate .= "<a href=\"".$scriptis."?position={$newoffset}&nresults={$nresults}{$extras}\">Next »</a>";
        }
        else
        {
            $paginate .= "<span class=\"pagination-disabled\">Next »</span>";
        }
    }
    if ( $nresults < $total_pages )
    {
        echo $paginate;
    }
}

Link to comment
https://forums.phpfreaks.com/topic/250723-syntax-error-help/#findComment-1286345
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.