Skip to content

Instantly share code, notes, and snippets.

@yesidays
Last active December 14, 2015 02:39
Show Gist options
  • Save yesidays/5015137 to your computer and use it in GitHub Desktop.
Save yesidays/5015137 to your computer and use it in GitHub Desktop.
Codeigniter-Combo
<?php
/* 1. En tu controlador deberás hacer la consulta a tu modelo */
//Controlador
function principal(){
$data = array(
'ciudades' => $this->miModelo_model->obtenerCiudades()
);
$this->load->view('miPagina', $data);
}
?>
/* 2. En tu vista obtienes esos datos y haces un foreach */
//Vista miPagina.php
<html>
....
<select>
<?php
foreach($ciudades->result() as $row) {
echo "<option id='.$row->idCiudad.' value='.$row->nombreCiudad'>" . $row->nombreCiudad . "</option>" ;
}
?>
</select>
</html>
Listo :)
@yesidays
Copy link
Author

Había un error en la generación del select.

Thanks @marco_garay por el feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment