Populate Dropdown List Using CodeIgniter

Submitted by: 
Language: 

In this code you’ll learn on how to populate a dropdown list using CodeIgniter. The list will be pulled from the function called “buildCountryDropdown” using helper.
The function is being called from the controller and then passed it to the view.
Here’s the code to call the helper and populate the array with values from our function:

  1. $this->load->helper('dropdown');
  2. $this->data['country'] = buildCountryDropdown('country', $this->input->post('country'));

When passed to the view, all you have to do is use this code:
<?php echo $country; ?>
Attached herewith is the application folder within the CodeIgniter framework.
To download the framework please visit Getting Started With CodeIgniter


Comments

Great tutorial! Please one more tutorial on dependent drop down list in codeigniter will be of great help. Thank you!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.