Last active
December 14, 2015 02:39
-
-
Save yesidays/5015137 to your computer and use it in GitHub Desktop.
Codeigniter-Combo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 :) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Había un error en la generación del select.
Thanks @marco_garay por el feedback