I found this artifac in my codeigniter helper hehe..
I used it to display array of data per page with these parameter :
1. $data = array of data
2. $currentpage = page you want to display
3. $rowperpage = number of data to display per page
4. $rowcount = number of data in $data (actually you can count it with count($data) 😀 silly me)
I hope this help someone although it need some adjustment
enjoy
function get_display_data($data, $currentpage, $rowperpage, $rowcount) { $numrowperpage = $rowperpage; $numrowtotal = $rowcount; $num_page = ceil($numrowtotal/$numrowperpage); if($num_page < $currentpage) $currentpage = $num_page; if($currentpage == 0) $currentpage = 1; $myoffset = $rowperpage * ($currentpage - 1); $array_data = array(); $num_display = (($rowcount-$myoffset) < $rowperpage) ? ($rowcount-$myoffset) : $rowperpage; for($i=$myoffset; $i<($myoffset+$num_display); $i++) { array_push($array_data, $data[$i]); } //return $array_data; $array = array('result' => $array_data, 'rowcount' => $rowcount, 'currentpage' => $currentpage, 'rowperpage' => $rowperpage); return $array; }
Reblogged this on kontinuiti.
Nice Share.. thank you.
You’r welcome, Enjoy
Reblogged this on ITechonology