Skip to content

Instantly share code, notes, and snippets.

@arifulhb
Created December 29, 2014 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arifulhb/745a0e194ea1aeae9ee3 to your computer and use it in GitHub Desktop.
Save arifulhb/745a0e194ea1aeae9ee3 to your computer and use it in GitHub Desktop.
Get total number of records based on keyword and search_by item.
public function getTotalSearchNum($keyword, $search_by){
$sql='SELECT cust_sn ';
$sql.='FROM (avcd_customer AS c) ';
switch ($search_by):
case 'name':
$sql.='WHERE c.cust_first_name LIKE "%'.$keyword.'%" OR c.cust_last_name LIKE"%'.$keyword.'%" ';
break;
case 'nric':
$sql.='WHERE c.cust_card_id LIKE "%'.$keyword.'%" ';
break;
case 'card_number':
$sql.='WHERE c.cust_id LIKE "%'.$keyword.'%" ';
break;
case 'car_number':
$sql.='WHERE c.cust_car_no LIKE "%'.$keyword.'%" ';
break;
endswitch;
$res=$this->db->query($sql);
return $res->num_rows();
}//end function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment