In these select I want to load the corresponding information for both, but I also want the select countries and cities, the selected country and city that the user has registered in the database, for the moment both functions work for me perfectly showing the countries and then the cities according to the country you select, but now I want that if you are already registered in the bd, come selected, in each function I receive the id_pais
and id_ciudad
in the variables $GLOBALS
, which are the id of the country and city that that user has registered in the bd, I hope you can help me
public function SelectPaisescontroller(){
$id_pais=$GLOBALS['id_pais'];
$respuesta = Datos::SelectPaisesModel("pais");
echo '<select class="form-control" name="id_pais" id="id_pais" value="'.$id_pais.'">';
echo '<option value="'.$id_pais.'">'.$respuesta['PaisNombre'].'</option>';
foreach ($respuesta as $row => $item){
echo '<option value="'.$item['id_pais'].'">'.utf8_encode($item['PaisNombre']).'</option>';
}
echo '</select>';
}
public function SelectCiudadescontroller($datos=null){
$datosController = $datos;
$id_ciudad=$GLOBALS['id_ciudad'];
echo '<select class="form-control" name="id_ciudad" id="id_ciudad" value="'.$id_ciudad.'">';
echo '<option value="0">Seleccione</option>';
$respuesta = Datos::SelectCiudadesModel($datosController, "ciudad");
foreach ($respuesta as $row => $item) {
echo '<option value="'.$item['id_ciudad'].'">'.utf8_encode($item['CiudadNombre']).'</option>';
}
echo '</select>';
}