Controller (invoice_invoice.php)
<?php
function sent() {
if (!null($this->input->get('id'))) {
$limit_per_page = 10;
$page = ($this->uri->segment(3)) ? ($this->uri->segment(3) - 1) : 0;
$total_records = $this->invoice_model->get_total_search($this->input->get('id'));
if ($total_records > 0) {
$params = array();
$params['content'] = $this->invoice_model->search($this->input->get('id'), $limit_per_page, $page * $limit_per_page);
//print_r($data);
//exit;
//$abc = count($data['content']);
$config['base_url'] = site_url() . '/invoice_invoice/sent';
$config['total_rows'] = $total_records;
$config['per_page'] = $limit_per_page;
$config["uri_segment"] = 3;
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$config['reuse_query_string'] = TRUE;
$config['full_tag_open'] = '<div class="pagination dataTables_paginate paging_bootstrap_number" id="sample_3_paginate"> <ul class = "pagination" style = "visibility : visible;">';
$config['full_tag_close'] = '</ul></div>';
/* $config['first_link'] = 'First Page';
$config['first_tag_open'] = '<span class="firstlink">';
$config['first_tag_close'] = '</span>'; */
//$config['last_link'] = 'Last Page';
//$config['last_tag_open'] = '<span class="lastlink">';
//$config['last_tag_close'] = '</span>';
$config['next_link'] = '<i class="fa fa-angle-right"></i>';
$config['next_tag_open'] = '<li class = "next">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '<i class="fa fa-angle-left"></i>';
$config['prev_tag_open'] = '<li class = "prev">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class = "active"><a>';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '<li>';
$this->pagination->initialize($config);
// build paging links
$params["links"] = $this->pagination->create_links();
}
}
}
My controller is taking call of id from the jquery to run it.
Here is my jquery
$(document).ready(function () {
$("#search").keyup(function () {
var str = $("#search").val();
if (str != "") {
console.log(str);
$.get("<?php echo base_url();?>invoice_invoice/sent?id=" + str, function (data) {
$("#sample_1").html(data);
});
}
});
});
sample_1 is the id of my table where i want to print the values coming from the search
Here is the view with the search block
<div class="row">
<div class="col-md-6 col-sm-6"><div
class="dataTables_length" id="sample_2_length">
<label>Show <select
name="sample_2_length" aria-controls="sample_2" class="form-control input-sm
input-xsmall input-inline">
<option value="5">5</option>
<option value="15">15</option>
<option value="20">20</option><option value="-1">All</option>
</select>
</label>
</div>
</div>
<div class="col-md-6 col-sm-6"><div id="sample_2_filter"
class="dataTables_filter">
<label>Search:
<input type="search" id ='search' name = 'search' class="form-control input-
sm input-small input-inline" placeholder="" aria-controls="sample_2">
</label>
</div>
</div>
</div>
Hereby is the model function
function search($search,$limit,$start)
{
$userdata1 = $this->session->userdata('condition');
$this->db->select("'id,Client_Name,ac_email,Client_email,Invoice_no,Items,client_add,Currency,Language,Notes'");
$whereCondition = array('Client_email' =>$search , 'ac_email' => $userdata1['ac_email'] );
$this->db->where($whereCondition);
$this->db->from('invoices');
$params = $this->db->get();
return $params->result();
}
I just want to search my data in the database and print it to the view . I have created the view as well as pagination is done but cant make the search going well. I just get "GET http://localhost/cidemo/invoice_invoice/sent?id=weqe@dsf 404 (Not Found)" error in my console where I run my search view