I am new to codeigniter, and using codeigniter 2.1.4. Here i have written query using datatables, but getting no results. In database respected values are there. I don't know what i did wrong, Kindly guide me. This is my code,
controller :
$this->load->library('datatables');
$this->datatables->select("sales.reference_no,sales.customer_name,sale_items.serial_no,sales.total,
sales.inv_discount,sales.total_tax2,sales.inv_total,users.username")->from('sales');
$this->datatables->join('sale_items', 'sales.id = sale_items.sale_id', 'left');
$this->datatables->join('users', 'sale_items.serial_no = users.id', 'left');
if($start_date) {
$this->datatables->where('sale_items.serial_no', $salesman, 'sales.date >=' $start_date, 'sales.date <=' $end_date);
}else{
$this->datatables->where('sale_items.serial_no', $salesman);
}
echo $this->datatables->generate();
Finally i got the answer for my question after taking more time. This is the correct one,
$this->load->library('datatables');
$this->datatables->select("sales.reference_no,sales.customer_name,sale_items.serial_no,sales.total,
sales.inv_discount,sales.total_tax2,sales.inv_total,users.username")->from('sales');
$this->datatables->join('sale_items', 'sales.id = sale_items.sale_id', 'left');
$this->datatables->join('users', 'sale_items.serial_no = users.id', 'left');
if($start_date) {
$this->datatables->where('sale_items.serial_no', $salesman, 'sales.date >=', $start_date, 'sales.date <=' , $end_date);
}else{
$this->datatables->where('sale_items.serial_no', $salesman);
}
echo $this->datatables->generate();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.