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>";

Link to comment
Share on other sites


if (isset($_GET

note: not tested


)){
$v=mysql_num_rows($resul)/$maxpage;
for($x=$_GET

;$x<=$v ;$x++){
	$count++;
	if($count == 5){
		 break;
	} 
}
}

 

dont quite understand

where about does this code go... and do i add anything to my echos?

 

Link to comment
Share on other sites


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

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.