I am working on a UNILEVEL MLM project & required to fetch data of users which is add by user. something went wrong in this code if i put $wh[] = "mobile_no = referred_by_id"; there is showing 1 result randomly but i need to verify through session. In this i used Mobile_no in session & in form of add member get entry of mobile no in referred_by_id. I need to show if session mobile no. matched in referred_by_id show all data there is showing only 1 randomly. Please help me
Model
public function get_all_users(){
$wh =array();
$SQL ='SELECT * FROM ci_users';
$wh[] = "$this->session->userdata('mobile_no') = referred_by_id";
if(count($wh)>0)
{
$WHERE = implode(' and ',$wh);
return $this->datatable->LoadJson($SQL,$WHERE);
}
else
{
return $this->datatable->LoadJson($SQL);
}
}
Controller
public function datatable_json(){
$records = $this->user_working->get_all_users();
$data = array();
foreach ($records['data'] as $row)
{
$status = ($row['is_active'] == 0)? 'inactive': 'active'.'<span>';
$disabled = ($row['is_admin'] == 1)? 'disabled': ''.'<span>';
$data[]= array(
ucfirst($row['firstname']),
$row['email'],
date('F j, Y',strtotime($row['created_at'])),
'<span class="btn bg-teal waves-effect" title="status">'.getGroupyName($row['role']).'<span>', // get Group name by ID (getGroupyName() is a helper function)
'<span class="btn bg-blue waves-effect" title="status">'.$status.'<span>',
'<a title="Delete" class="delete btn btn-sm btn-danger pull-right '.$disabled.'" data-href="'.base_url('user/users/del/'.$row['id']).'" data-toggle="modal" data-target="#confirm-delete"> <i class="material-icons">delete</i></a>
<a title="View" class="view btn btn-sm btn-info pull-right" href="'.base_url('user/users/edit/'.$row['id']).'"> <i class="material-icons">visibility</i></a>',
);
}
$records['data']=$data;
echo json_encode($records);
}