I am using pagination for searched results. Searching is working perfectly. The first 10 records are shown after the search. But when I click the next button everything disappears and an empty page is displayed.
Any ideas what might be wrong in my code would be appreciated.
Model
function search_bookings($time, $title, $payment, $start_date, $end_date,$limit, $start, $type) {
$this->db->select('reservations.*');
$this->db->from('reservations');
$this->db->where('is_deleted', '0');
$this->db->order_by('date_cal',"desc");
if (!empty($time) && !is_null($time)) {
$this->db->where('reservations.type', $time);
}
if (!empty($payment) && !is_null($payment)) {
$this->db->where('reservations.advanced_payment_status', $payment);
}
if (!empty($title) && !is_null($title)) {
$this->db->where('reservations.title', $title);
}
if (!empty($start_date) && !is_null($start_date)) {
$this->db->where('reservations.date_cal >=', $start_date);
$this->db->where('reservations.date_cal <=', $end_date);
}
if ($type == 'half') {
$this->db->limit($limit, $start);
}
$query = $this->db->get();
return $query->result();
}
Controller
function search_reservations($start = 0) {
$reservation_service = new Reservation_service();
$config = array();
$config["base_url"] = site_url() . "/dashboard/manage_bookings/";
$config["per_page"] = 10;
$config["uri_segment"] = 4;
$config["num_links"] = 4;
$time = $this->input->post('type', TRUE);
$title = $this->input->post('title', TRUE);
$payment = $this->input->post('payment', TRUE);
$date_from = $this->input->post('date_from', TRUE);
$date_to = $this->input->post('date_to', TRUE);
$searched_results = $reservation_service->search_bookings($time, $title, $payment, $date_from, $date_to, $config["per_page"], $start, 'half');
$data['search_results'] = $searched_results;
$config["total_rows"] = count($reservation_service->search_bookings($time, $title, $payment, $date_from, $date_to, $config["per_page"], 0, 'all'));
$this->pagination->initialize($config);
$data["links"] = $this->pagination->create_links();
$this->load->view('body_pages/search_results', $data);
}
Search results view
<table class="display table table-bordered table-striped" id="bookings_table">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Hall</th>
<th>Time</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($search_results as $result) {
?>
<tr id="bookings_<?php echo $result->id; ?>">
<td><?php echo ++$i; ?></td>
<td><?php echo $result->date_cal; ?></td>
<td><?php if ("RP" == $result->title) { ?><?php
echo "Royal Princess Ballroom (Downstairs)";
}
?>
<?php if ("GK" == $result->title) { ?><?php
echo "Grand Kings Ballroom (Upstairs)";
}
?>
</td>
<td><?php echo $result->type; ?></td>
<td align="center">
<a class="btn btn-primary btn-xs" onclick="display_edit_reservation_pop_up(<?php echo $result->id; ?>)"><i class="fa fa-pencil" title="Update"></i></a>
<a class="btn btn-danger btn-xs" onclick="delete_bookings(<?php echo $result->id; ?>)" ><i class="fa fa-trash-o " title="Remove"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="pagination">
<?php echo $links; ?>
</div>