Very good and tried to put in a selected control the option "Select an option" but it does not work for me, the combo is loading data from the database, I'm using the codeigniter framework, I would like someone to guide me in it to be able to load
Here the code
users_model.php
public function get_categorias(){
$query = $this->db->query('SELECT COD_MODA,NOM_MODA FROM cmi_moda');
if ($query->num_rows()>0)
foreach($query->result() as $row){
$datos[($row->COD_MODA)] = $row->NOM_MODA;
}
$query->free_result();//libera la memoria despues de usar el foreach cuando se tiene bastante data
return $datos;
}
Part of the view where the selected views / frontend is
Users.php
<div class="form-group">
<label class="col-lg-1">Modalidad:</label>
<div class="col-md-2">
<select name="Categorias" class="form-control">
<?php
foreach ($datos as $i => $categoria){
echo '<option values="',$i,'">',$categoria,'</option>';
}
echo print_r($datos);
echo var_dump($datos);
?>
</select>
</div>
Driver users.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Usuarios extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('Usuarios_model');
}
public function index()
{
// $this->load->view('frontend/usuarios');
// obtenemos el array de profesiones y lo preparamos para enviar
$datos['datos'] = $this->Usuarios_model->get_categorias();
// cargamos la interfaz y le enviamos los datos
$this->load->view('frontend/usuarios',$datos);
}
I would like to achieve this option Choose an option that displays the option