2018-05-09 02:50
浏览 60


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


public function get_all_users(){
        $wh =array();
        $SQL ='SELECT * FROM ci_users';
        $wh[] = "$this->session->userdata('mobile_no') = referred_by_id";
            $WHERE = implode(' and ',$wh);
            return $this->datatable->LoadJson($SQL,$WHERE);
            return $this->datatable->LoadJson($SQL);


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(
                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>',

        echo json_encode($records);                        
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douren7179 2018-05-09 04:22

    The session could not be converted to the string & you are passing the session value to the column to check in the query

    update your $wh[] by the following code

    $wh[] = "`referred_by_id` = '{$this->session->userdata('mobile_no')}'";
    点赞 评论

相关推荐 更多相似问题