er0x Posted October 6, 2007 Share Posted October 6, 2007 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 https://forums.phpfreaks.com/topic/72065-solved-pagination-showing-page-0-and-1-bc-of-range/ Share on other sites More sharing options...
teng84 Posted October 6, 2007 Share Posted October 6, 2007 if (isset($_GET )){ $v=mysql_num_rows($resul)/$maxpage; for($x=$_GET ;$x<=$v ;$x++){ $count++; if($count == 5){ break; } } } note: not tested Link to comment https://forums.phpfreaks.com/topic/72065-solved-pagination-showing-page-0-and-1-bc-of-range/#findComment-363136 Share on other sites More sharing options...
er0x Posted October 6, 2007 Author Share Posted October 6, 2007 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 https://forums.phpfreaks.com/topic/72065-solved-pagination-showing-page-0-and-1-bc-of-range/#findComment-363140 Share on other sites More sharing options...
teng84 Posted October 6, 2007 Share Posted October 6, 2007 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 https://forums.phpfreaks.com/topic/72065-solved-pagination-showing-page-0-and-1-bc-of-range/#findComment-363147 Share on other sites More sharing options...
er0x Posted October 6, 2007 Author Share Posted October 6, 2007 i fixed my problem... i just threw this in there if ($i < 2){$i = 1;} Link to comment https://forums.phpfreaks.com/topic/72065-solved-pagination-showing-page-0-and-1-bc-of-range/#findComment-363152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.