I am trying to create an HTML select field with option tags built from database values in CodeIgniter
When I try to retrieve the data of the database to the dropdown it only displays the first letter instead of the full database value text.
My view:
<select name="country" style="width: 200px;">
<?php
foreach ($countries as $country) {
echo '<option value="' . $country['PKCOUNTRY'] . '">' . $country['COUNTRYNAME'] . '</option>';
}
?>
</select>
My model:
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;
}
}
}
My controller:
class countries extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('Countries_model');
}
public function country()
{
$this->load->database();
$data['countries'] = $this->Countries_model->get_countries();
$this->load->view('countries_view', $data);
}
}

arrayto$newarray['PKCOUNTRY'] = 'COUNTRYNAME'then use theform_dropdown('country',$newarray)option?