I am simply run a query inside my model code mention below:
public function friend($name)
{
$arr = explode(" ",$name);
$fname = $arr[0];
$lname = $arr[1];
$this->db->select('*');
$this->db->from('client');
$where = "fname='".$fname."' and lname='".$lname."'";
$this->db->where($where);
$sql = $this->db->get();
if($sql->num_rows() > 0)
{
$result = $sql->result_array();
return $result;
}
else
{
$this->session->set_userdata('err','<p style="color:red;">No information found!</p>');
}
}
Suppose $name='Jhon Carter'
and I use explode
function to get firstname
& lastname
. I have two columns in my table i.e fname and lname
. I want to get data according to these columns So How can I do this? Please help me.
Thank You