Welcome Guest, Not a member yet? Register   Sign In
dynamic menu from database
#1

[eluser]ranggadablues[/eluser]
Hi there, I'm new in codeigniter and I'm sorry if my english not so good..

I have a website that left panel and right panel, on left panel I use for menu and right panel I use for product detail. And my menu I use database, because I want that my web have a dynamic menu, but I don't know how to implement in codeigniter when I click one of the left panel menu and right panel is showing from menu that I was click

here's my script:
model
Code:
function show_all_produk() {
  $this->db->select('*');
  $this->db->from('product');
  $this->db->where('show_all','1');
  $this->db->order_by('produk_id','ASC');
  $produk = $this->db->get();
  return $produk->result();
}

function load_menu() {
  $this->load->database();
  $menu = $this->db->query('select nama_menu from menu');
  return $menu->result();

controller
Code:
function store()
{
  $data['produk'] = $this->Pgallery_model->show_all_produk();
  /*daftar menu*/
  $data['menu'] = $this->Pgallery_model->load_menu();
  $this->load->view('store', $data);
}

and my view
Code:
<!-- left panel -->
<div id="leftmenu">
  <ul id="navigation">
   &lt;?php if (isset($menu) && count($menu)):
   foreach($menu as $menus): ?&gt;
   <li><a id="link" href="#">&lt;?php echo $menus->nama_menu; ?&gt;</a></li>
   &lt;?php endforeach; else:
   endif; ?&gt;
  </ul>
</div>
&lt;!-- end left panel --&gt;

&lt;!-- right panel --&gt;
<div id="rightpanel">
  <ul>  
   &lt;?php if (isset($produk) && count($produk)):
   foreach($produk as $row): ?&gt;
   <div id="product">
   <div class="boxgrid captionfull">  
   <li><img src="&lt;?php echo $row-&gt;imageurl;  ?&gt;" />
    <div class="cover boxcaption">
     <h3>Nama Produk</h3><br/>
     <p><a href="#">Lihat detail</a></p>
    </div>
    <div>&lt;?php echo $row->nama; ?&gt;</div>
   </li>
   </div>
   </div>
  &lt;?php endforeach; else: endif; ?&gt;
  
  </ul>
</div>
&lt;!-- end right panel --&gt;

please advice?
thank you
#2

[eluser]ranggadablues[/eluser]
anyone?
who can give me advice?

thank you
#3

[eluser]Mauricio de Abreu Antunes[/eluser]
Code:
function show_all_produk() {
  $this->db->select('*');
  $this->db->from('product');
  $this->db->where('show_all','1');
  $this->db->order_by('produk_id','ASC');
  $produk = $this->db->get();
  return $produk->result();
}

Please, put a print_r function, printing your result array.
Code:
print_r($produk->result());
#4

[eluser]ranggadablues[/eluser]
i found my solutions

thank you




Theme © iAndrew 2016 - Forum software by © MyBB