public function getBulletin($startdate, $enddate, $volId) { try { $records_per_page = 30; $pagination = new Pagination(); $pagination->navigation_position(isset($_GET['navigation_position']) && in_array($_GET['navigation_position'], array('left', 'right')) ? $_GET['navigation_position'] : 'outside'); $where = ''; $all = ''; if (trim($startdate) && trim($enddate) && $volId != 'all') { $where = " AND bu_date BETWEEN :startdate AND :enddate "; } else { if (trim($startdate) && trim($enddate) == '') { $where = " AND bu_date >= :startdate "; } else { if (trim($startdate) == '' && trim($enddate)) { $where = " AND bu_date <= :enddate "; } } } if ($volId != 'all') { $all = 'vd_id = :volId'; } $where = "WHERE " . $all . $where; //echo "SELECT SQL_CALC_FOUND_ROWS * FROM bu_pdf $where ORDER BY bu_date DESC LIMIT"; $pdo = $this->db->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM bu_pdf {$where} ORDER BY bu_date DESC LIMIT " . ($pagination->get_page() - 1) * $records_per_page . ', ' . $records_per_page); if ($volId != 'all') { $pdo->bindparam(":volId", $volId); } if (trim($enddate)) { $pdo->bindparam(":enddate", $enddate); } if (trim($startdate)) { $pdo->bindparam(":startdate", $startdate); } $pdo->execute(); $pdo2 = $this->db->prepare("SELECT FOUND_ROWS() AS `found_rows`"); $pdo2->execute(); $totalrows = $pdo2->fetch(PDO::FETCH_ASSOC); $total_rows = $totalrows['found_rows']; // pass the total number of records to the pagination class $pagination->records($total_rows); // records per page $pagination->records_per_page($records_per_page); //$pbo->execute(array(':edate'=>$enddate)); $tbl = '<table class="table table-striped"> <thead> <tr> <th>Code</th> <th>Description</th> <th>Date</th> <th>Bulletin</th> </tr> </thead> <tbody>'; while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) { $tbl .= ' <tr> <td>' . $row['bu_code'] . '</td> <td>' . $row['bu_description'] . '</td> <td>' . $row['bu_date'] . '</td> <td><a href="/cm_image/bulletin/' . $row['bu_file'] . '" target="_blank">View</a></td> </tr>'; } echo $tbl .= '</tbody></table>'; echo '<div class="clear text-center">'; // render the pagination links $pagination->render(); echo '</div>'; } catch (PDOException $e) { die('ERROR: ' . $e->getMessage()); } }