简体   繁体   中英

my dropdown displays only one first alphabet of the data from the database

i am trying to code in codeigniter using mysql database and using the html tags...now when i try to retrieve the data of the database to the dropdown it only displays the first alphabet.I am using the following code in 使用以下代码

<select name="country" style="width: 200px;">
  <?php
    foreach($countries as $country)
    {   
       echo '<option value="'.$country['PKCOUNTRY'].'">'.$country['COUNTRYNAME'].'</option>';
    }
  ?>
</select>

<?php

class Countries_model extends CI_Model {

public function __construct() {

    parent::__construct();

}

public function get_countries() {

    $query = $this->db->get('ISaathiDev.MCountry');
        if ($query->num_rows >= 0)
        {
            foreach($query->result_array() as $row)
            {
                $data[$row['pkCountry']]=$row['CountryName'];
            }
            return $data;
        }
}

} ?>

<?php

class countries extends CI_Controller {

public function __construct()
{

    parent::__construct();
    $this->load->model('Countries_model');
}

public function hey()
{
}


public function country()
{
    //$this->load->view('u_view');
    //log_message('debug', 'hey :Construct');
    //$this->load->view('u_view');
    $this->load->database();
    $data['countries']=$this->Countries_model->get_countries();
    $this->load->view('countries_view',$data);
}   

}

?>

在此处输入图片说明

Please use the folloing code:

get_Countries(){ $this->db->select('pkCountry,CountryName'); return $this->db->get('ISaathiDev.MCountry')->result_array(); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM