it shows me this error http://prntscr.com/umlamf and I have this code
Controller:
public function index()
{
$data['polozky'] = $this->cetba_model->get_menu();
$this->load->view('templates/header', $data);
$this->load->view('pages/ctenari', $data);
$this->load->view('templates/footer');
}
View:
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<?php foreach($polozky as $p): ?>
<li class ="nav-item">
<a class="nav-link" href="<?php echo base_url()?> <?= $p->polozka_menu ?>"><?= $p->polozka_menu?><span class="sr-only">(current)</span></a>
</li>
<?php endforeach; ?>
</ul>
</div>
And this model:
<?php
class cetba_model extends CI_Model
{
public function get_menu()
{
$this->db->order_by('idmenu');
$query = $this->db->get($this->menu);
return $query->result();
}
}
I don't know, what to do to make it work, can someone help me, please?
order_by() function require two-parameter
The first parameter contains the name of the column you would like to order by.
The second parameter lets you set the direction of the result. Options are ASC, DESC, and RANDOM.
in $this->db->get('') you should provide your table name. following code hope will sort out your problem
<?php
class cetba_model extends CI_Model
{
public function get_menu()
{
$this->db->order_by('idmenu','ASC');
$query = $this->db->get('your_table_name');
return $query->result();
}
}
and in your controller do not forget to call your model, like this
$this->load->model('model_name')