query($sql))){ die (DB::errorMessage($res)); } // $from is received for example as url param: // http://www.host.com/list.php?from=50 // $limit is the number of rows you want to display per page if (isset($_GET['from'])){ $from=$_GET['from']; }else{ $from=0; } $limit = 10; $pager = new DB_Pager ($res, $from, $limit); // $data now contains all the data needed to build // for example, links and displaying info to the user $data = $pager->build(); if (DB::isError($data)){ die (DB::errorMessage($data)); }if (!$data) { die ('There were no results'); } // Display data (only few examples) echo ''; echo $data['numrows'] . ' Results found'; echo '
'; echo 'Page '. $data['current'] . ' of ' . $data['numpages']; echo '
'; echo $data['limit'] . ' results per page'; echo '
'; //new line // Previous button echo ' '.' <-prev'; // Direct link to pages foreach ($data['pages'] as $page => $start_row) { echo '| '.$page.''; } // Next button // echo ' '.$data['remain'].' next->'; echo ' '.' next->'; // Automatically fetch only the rows for this page. // fetchInto() is also avaible while ($row = $pager->fetchRow(DB_FETCHMODE_ASSOC)){ echo "
".$row['nr_arid']."|".$row['nr_title'] . "\n"; } echo ''; // Database disconnect $res->free(); $con->disconnect(); ?>