Selection of countries by select from the database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Selection of countries by select from the database (/showthread.php?tid=70291) |
Selection of countries by select from the database - grechca - 03-21-2018 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. RE: Selection of countries by select from the database - ivantcholakov - 03-21-2018 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. RE: Selection of countries by select from the database - grechca - 07-28-2018 @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. |