Jumat, 12 Juli 2013

Examples for pager_query()

Syntax :
pager_query($query, $limit = 10, $element = 0, $count_query = NULL)

Table format Pager :
 if you want to display the data as a table format, you can use the following example:
/**To get the records, first we need to have a query for total records. I am taking an example of node table records.**/
$sql_count = "SELECT count(*) FROM node";
 $sql = pager_query("SELECT * FROM node",5,0,$sql_count); //5 - limited pages to show
 $nodeContent = array();
 while($row = db_fetch_object($sql)){
    $createdDate = date('jS M, Y',$row->created);
    $nodeContent[] = array( $row->nid, $row->title, $createdDate);
 }
 // to set the table header titles
 $tableHeader = array('Nid','Title','Date');
 // to get the table format
 $output .= theme('table', $tableHeader, $nodeContent);
 // get the pager
 $output .= theme('pager', NULL, 5, 0);
 return $output;
- from here : http://www.drup-all.com/blog/examples-pagerquery

Senin, 01 Juli 2013