Selection of countries by select from the database |
Hello.
I'm just starting to learn CodeIgniter. I have a question. The database created a table of countries and fields. PHP Code: CREATE TABLE IF NOT EXISTS `country` ( At the moment I have on the page when registering the user, I need to write the country in the text field. PHP Code: <input class="form-control required" name="country" type="text" placeholder="<?php echo translate('country');?>" data-toggle="tooltip" title="<?php echo translate('country');?>"> I want the country instead of the field: Select the select from the bats from the table country. How to do it? Help me please.
A model:
Code: <?php In a controller: Code: $this->load->helper('form'); In the corresponding view: Code: echo form_dropdown('country_code', $country_list, '' /* set_value('country_code', $country_code) */ , 'id="country_code" class="form-control required"'); This example could be simplified, bu I did not do it intentionally, for better readability.
@ivantcholakov
1. Created the model /application/models/Countries_model.php Added your code. 2. In the file Home / application /controllers/Home.php added your code. In file /application/views/front/user/register/index.php How to insert your code? echo form_dropdown ('country_code', $ country_list, '' / * set_value ('country_code', $ country_code) * /, 'id = "country_code" class = "form-control required"'); If I have a choice form select. Help me please. |
Welcome Guest, Not a member yet? Register Sign In |