aii guys....really stuck up here...my attempt paginating my recordset no to avail...so far..I manage to get display the numbering for the total record as u can see here...
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
my desire just wanna display previous and next and next 10 record till reach total records
as u can see here..
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
somerecord
previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 next
after user click next it will display another 20 records
previous 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 next and so forth..
Hope someone will shed me some light...here's the mockup illustration waht I after..
testpaging.php
include("DataBase.class.php");
include("Pagination.class.php");
$db = DataBase::getInstance();
$row = $db->executeGrab("SELECT * FROM ".PADU_NOTICE." WHERE DEPARTMENT_CODE='04'");
if($row){
$numRows = $db->getNumRow();
if(isset($_GET['p'])){
$pg = $_GET['p'];
}else{
$pg = 1;
}
$targetPage = $_SERVER['PHP_SELF'];
$pager = Pagination::getInstance($row, $pg, $targetPage, 20,$numRows);
if(is_object($pager)){
foreach($pager->__getPage($pg) as $item) {
echo 'NOTICE NO :: '.$item['NOTICE_NO'].'<br>';
}
echo "<br/>\n";
echo "<br/>\n";
echo "<br/>\n";
echo "<div align='center'>".$pager->__getNav()."</div>";
}
}
here's the paginationclass
class Pagination{
static private $instance = false;
public $_properties;
public $pages;
public $data = array();
public $_pageNum;
public $_targetPage;
public $_perPage;
public $_nav;
private $_numrows;
private function __construct($data, $pageNum, $targetPage, $perPage, $numRows){
$this->_data = $data;
$this->_pageNum = $pageNum;
$this->_targetPage = $targetPage;
$this->_perPage = $perPage;
$this->_numrows = $numRows;
$this->pages = array();
$this->buildPaging($this->_data);
$this->buildNav();
}
public static function getInstance($data=NULL, $pageNum=NULL, $targetPage=NULL, $perPage=NULL, $numRows=NULL){
if(!Pagination::$instance) {
Pagination::$instance = new Pagination($data, $pageNum, $targetPage, $perPage, $numRows);
}
return Pagination::$instance;
}
public function __set($name, $value) {
if(isset($name)) {
$this->_properties[$name] = $value;
}
}
public function __get($name){
if(isset($this->_properties[$name])){
return $this->_properties[$name];
}else{
return NULL;
}
}
public function buildPaging($dataArr=NULL){
if(is_array($dataArr)){
$numberPages = count($dataArr)/$this->_perPage;
if (round($numberPages)<$numberPages) {
$numberPages = round($numberPages) + 1;
}
$k=0;
for ($i=0;$i<$numberPages;$i++){
for($j=0;$j<$this->_perPage;$j++){
if(isset($dataArr[$k])){
$this->pages[$i][$j] = $dataArr[$k];
}
$k++;
}
}
}
}
/////////////////////////////portions printing the numbering//////////////////////////////
//need help here..
public function buildNav(){
$this->_nav = '';
foreach($this->pages as $key => $page){
if($key == $this->_pageNum){
$style = ' style="font-weight:bold;text-decoration:none;color:#000;"';
} else {
$style = '';
}
$this->_nav .= '<a href="' .$this->_targetPage. '?page=' .$key. '"' . $style . '>' .$key. '</a> ';
}
}
///////////////////////////////////////////////////////////////
public function __getNav() {
return $this->_nav;
}
public function __getPage($num) {
return $this->pages[$num-1];
}
public function __clone(){
trigger_error("Clone is not allowed.", E_USER_ERROR);
}
}
Hope someone will shed me some light..thanks you in advanced