donglinxi1467 2015-08-11 13:48
浏览 22
已采纳

如何在codeigniter中分别获取每个管理员创建的用户?

i have a Codeigniter system where Admin creates Reseller. So in reseller table values like name,country,phone,email,key,user_number, are stored. Whatever value is in user_number that much blank rows are created in users table. So reseller key is mapped to that user rows. if reseller asks for 10 user than 10 blank rows are created in user table mapped to his key.

Now once a reseller is created he can login and can edit his users i.e(he can fill in the user details)

Now my issues is that i want to fetch only the users mapped to currently loggedin reseller and not all the users in table. I dont know how to do this please help:

below is my Code where i fetch all the users for a reseller :

Controller:

public function index ()
{
    // Fetch all users


    $session_data = $this->session->userdata('logged_in');
    $id = $session_data['id'];

    $data['users'] = $this->user_m->get_users($id);


    // Load view
    $this->data['subview'] = 'reseller/user/index';
    $this->load->view('reseller/_layout_main', $this->data);


}

The Model function:

public function get_users(){

    $query = $this->db->get_where('users', array('key' => $id));   

    if($query -> num_rows() > 1)
    {
    return $query->result();
    }
    else
    {
   return false;
    }


   }

I have tried to fetch the users but got stucked with errors! please help me with code. i just need to show user mapped by key of reseller. So reseller should only see his own users and not others!

  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于用matlab进行光束整形的问题
      • ¥15 vs code编译器 C语言刚学,想的有点复杂
      • ¥15 航班订票系统函数无法运行
      • ¥20 VS2022无法启动程序,如何解决?(语言-c++|开发工具-visual studio)
      • ¥15 c语言可以做出完整的吗有人看看吗
      • ¥15 电脑流氓插件处理方法
      • ¥15 问一下这个可调恒流源电路用哪个电源接口比较好,想用tapec接口仅作为电源接口这个引脚怎么连啊
      • ¥30 Abaqus做建模的时候网格没办法收敛是为什么?
      • ¥15 车牌识别摄像镜头,httppost,nodejs
      • ¥20 腾讯云托管与本地测试 GET请求获取返回值 完全不同