Jump to content

[SOLVED] pagination showing page 0 and -1 b/c of range???


er0x

Recommended Posts

ok, im trying to add a range to my pagination script. i have a range set up for 5 pages are shown...

but when on page 1 it shows this ... -1 . 0 . 1 . 2 . 3      same on page 2 just over one more

 

how the hell do i take that off? i am going to widen the range from 2 away to about 6 or 7 away... so i cant have lots of negative numbers... heres the code

 

echo "<div id=\"pages\">";
    // use $result here to output page content 

    // output paging system (could also do it before we output the page content) 
    if ($ctbpage == 1) // this is the first page - there is no previous page 
        ; 
    else            // not the first page, link to the previous page 
        echo "<ul><li><a href=\"?page=test&ctbpage=" . ($ctbpage - 1) . "\"> << </a></li>"; 

for ($i = $pager->ctbpage - 2; $i <= $pager->ctbpage + 2; $i++) { 
          if ($i == $pager->ctbpage) 
            echo "<li class=\"current\">$i</li>"; 
        else 
            echo "<li><a href=\"?page=test&ctbpage=$i\">$i</a></li>"; 
    } 

    if ($ctbpage == $pager->numPages) // this is the last page - there is no next page 
        ; 
    else            // not the last page, link to the next page 
        echo "<li><a href=\"?page=test&ctbpage=" . ($ctbpage + 1) . "\"> >></a></li>"; 
echo "</ul></div><br><br>";


if (isset($_GET

)){//check whether url pas a get value for paging
$v=mysql_num_rows($resul)/$maxpage; // devide the number of rows in your db to the number of records you want to display per page
for($x=$_GET

;$x<=$v ;$x++){// loop the number of record to determine where to start and end eg 2-6
	$count++;// count to determine if youreach 5 pages to be shown
	if($count == 5){//check if youreach five page then escape the loop
		 break;
	} 
}
}

// look i dont know where to insert this because your using $pager which i believe is your paging class so
// from this example try to figure it out

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.