piyus168 Posted March 31, 2007 Share Posted March 31, 2007 hi alli am new to php,i am creating a project of forum.i want that if there are more than 20 replies than the other replies should be displayed in next page.as show belowFirst Next 1 2 3 Prev Lastjust like this i want to use this feature in my forum,can any body help me..please help its urgent...thanks to all Link to comment Share on other sites More sharing options...
vijay Posted March 31, 2007 Share Posted March 31, 2007 Hi...yea sure.. and in phpclass.org many readymade paging is available you can go 4 that..refere the following code.. you will ge the things..here I have simple code... for ($i=1;$i<=32;$i++){ $cnt[$i]=$i; }// consider $cnt is a result set frm ur db$total=count($cnt);$limit=5;if(is_numeric($_REQUEST['start']) && $_REQUEST['start'] <= $total){ $start=$_REQUEST['start'];}else { $start=1;}if($total - $start < $limit){ $start= $start - ($total % $limit) -1;}$end = $start + $limit;if($start > $limit) $prev=$start-$limit; echo "<br/>";echo "<a href='?start=$prev'>Prev.</a> "; for($i=$start;$i < $end;$i++) echo $cnt[$i]." ";if($next <= $total) echo "<a href='?start=$end'>Next</a>"; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now