[eluser]eggzy[/eluser]
I have a model function for getting categories:
Code:
public function get_cats() {
$this->db->order_by('title', 'asc');
$query = $this->db->get('labels');
if($query->num_rows() > 0) return $query->result();
else return NULL;
}
and in controller:
Code:
$categories = $this->posts_m->get_cats();
foreach ($categories as $category) {
$options[$category->id] = $category->title;
}
$data = array('dropdown' => $options);
and this populates dropdown for choosing category:
Code:
<?php echo form_dropdown('cats', $dropdown, ''); ?>
But when there are no categories in DB it shows errors.
It would be nice to show just empty dropdown.