How can i retrieve a column values from my database table and show it as a drop down box in php with codeigniter.
Simply write a function in one of your models (application/models) that fetches all the data you want. Something like:
public function getTags()
{
$this->db->select('id,tag_name');
$this->db->order_by('tag_name', 'ASC');
$query = $this->db->get('tags');
return $query->result();
}
Then you have to load that model file in the controller, and finally in your view file try something like this:
<?php foreach($this->model_name->getTags() as $tagData): ?>
<li>
<h2><a href="/tags/<?php echo $tagData->id; ?>"><?php echo $tagData->tag_name; ?></a></h2>
</li>
<?php endforech; ?>
where model_name is your model. You only need to style your html as a dropdown. You can get more information in here