• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display dynamic menu and menu display rolewise login in Codeigniter

#1
hello everyone i need help in codeigniter dynamic menu, here i shown my two table 1st is category and 2nd is user_registration,
so here i want to display menu rolewise login
suppose 1st is admin so admin will shown all menus,
and 2nd is user so here i want to display them only 1,2 and 6 menu,
here two tabel give cid is foriegn kesy, so how to join this table and how to disple menu userwise login
so how to impelment in codeigniter give me hint


*Category
cid    cname         parentID      

 1      Home                0          
 2     Marketing           0             
 3     Customer           2             
 4     Quoation            2                 
 5     New Customer    3         
 6     view Customer    3




*user_registration
userid  roll_id   fullname    username        password           cid
  1        1           admin     admin@gmail.com   admin         1,2,3,4,5,6
  2        2          user         user@gmail.com        user          1,2,6
Reply

#2
PHP Code:
$categories explode(','$user->cid);
// $categories = [1, 2, 6]

$q $this->db
    
->select('*')
    ->
where_in('cid'$categories)
    ->
get('category'); 

Is that what you mean?
Reply

#3
(07-23-2018, 01:28 AM)Pertti Wrote:
PHP Code:
$categories explode(','$user->cid);
// $categories = [1, 2, 6]

$q $this->db
    
->select('*')
 
   ->where_in('cid'$categories)
 
   ->get('category'); 

Is that what you mean?

i did not understand
Reply

#4
(07-23-2018, 02:04 AM)jaydevvara Wrote: i did not understand

You asked how can you join these tables.

It's not really question of join, but I've shown you how you can get categories based on what user_reg table has.

It does not take account, for now, the parent categories, but it's a start.
Reply

#5
(07-23-2018, 03:05 AM)Pertti Wrote:
(07-23-2018, 02:04 AM)jaydevvara Wrote: i did not understand

You asked how can you join these tables.

It's not really question of join, but I've shown you how you can get categories based on what user_reg table has.

It does not take account, for now, the parent categories, but it's a start.
yes got it but i did not fetch id in this condition

Code:
where_in('cid', $categories)
Reply

#6
(07-23-2018, 03:08 AM)jaydevvara Wrote:
(07-23-2018, 03:05 AM)Pertti Wrote:
(07-23-2018, 02:04 AM)jaydevvara Wrote: i did not understand

You asked how can you join these tables.

It's not really question of join, but I've shown you how you can get categories based on what user_reg table has.

It does not take account, for now, the parent categories, but it's a start.
yes got it but i did not fetch id in this condition

Code:
where_in('cid', $categories)

And here is my category table fetch  query so how implement  in this code


 public function listMenuLevel1() {

        $this->db->select("*");
       
        $this->db->where('parent_id=0');

        return $this->db->get('category')->result();
        return result;
    }

    public function listchildMenus($category_id) {

        $this->db->select("*");
        $this->db->where('parent_id', $category_id);
        return $this->db->get('category')->result();
   
        return result;
    }
Reply

#7
There are some good replies on recursively fetching parent entries here - https://stackoverflow.com/questions/2021...sive-query
Reply

#8
(07-23-2018, 03:48 AM)Pertti Wrote: There are some good replies on recursively fetching parent entries here - https://stackoverflow.com/questions/2021...sive-query

Thank you sir Wink
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.