I've been trying to get the PEAR pager to work with no luck. How do I use the pear::pager package? or more specifically the pager_wrapper_db.php. the example.php that I found in the doc/examples/ works fine. but I can't get anything to work with a mysql resultset. below is what I've got so far, but doesn't seem to be working. I can get the links and the paging working but I cant get any of the data out of the resultset.
I can't really find any good examples online. any help would really be appreciated. thanks in advanced
I can't really find any good examples online. any help would really be appreciated. thanks in advanced
| Code: |
|
<?php require_once 'config.php'; //db connect variables require('DB.php'); require 'Pager/Pager.php'; $dsn = $dbengine.'://'. $dbuser.':'. $dbpass.'@'. $dbhost.'/'. $dbname; $db = DB::connect($dsn, TRUE); if(DB::isError($db)) { die($db->getMessage()); } $db->setFetchMode(DB_FETCHMODE_ASSOC); $query = "select * from messages"; require_once 'Pager_Wrapper.php'; $pagerOptions = array( 'mode' => 'Sliding', 'delta' => 2, 'perPage' => 10); $paged_data = Pager_Wrapper_DB($db, $query, $pagerOptions); echo '<html><body>'; //I don't know how to get the data from the resultset out of the $paged_data echo 'total: '.$paged_data['page_numbers']['total'].'<br />'; //this works echo 'current: '.$paged_data['page_numbers']['current'].'<br />'; //this works echo $paged_data['links']; //this works while ($row = $paged_data['data']->fetchRow()) {// This is where I don't know what to do to get the data out echo $row['msg_id']; } echo '</body></html>'; ?> |
