/ Published in: PHP
Couldent find a pre-made function with a simple pagination.
$curent_page Is what page number you are currently on. $totalcontent Is how many rows you have in your database $perpage Is how many rows you display per page.
Expand |
Embed | Plain Text
<?php function dopages($curent_page, $totalcontent, $perpage){ $totalpages = $totalcontent / $perpage; if($curent_page !== 1){ $preid = $curent_page - 1; $output .= '<a href="'.$preid.'">Previous</a> '; } while ( $counter <= $totalpages ) { if($counter == $curent_page){ $output .= '<a href="'.$counter.'"><b>'.$counter.'</b></a> '; }else { $output .= '<a href="'.$counter.'">'.$counter.'</a> '; } $counter = $counter + 1; } if($curent_page !== $totalpages){ $neid = $curent_page + 1; $output .= '<a href="'.$neid.'">Next</a> '; } return $output; } ?> //usage
You need to login to post a comment.
