I have this query to a database, the problem is that the query works only when it receives the code AFG , with any other countrycode (example DEL) returns nothing. I haven't got conection error , using AFG code WORK but with any other that exists no
the database scheme is world -> city -> id , Name , CountryCode , District , Population
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "world";
$respuesta = [];
$selec = $_GET["selected"];
$ms = mysqli_connect($host, $user, $pass);
if (!$ms){
$mensaje = 'ERROR: No pude conectar al servidor MySQL';
}else{
if (mysqli_select_db($ms, $db)){
$q = "SELECT * FROM `city` WHERE `CountryCode`='".$selec."'";
$r = mysqli_query($ms, $q);
while($row = mysqli_fetch_assoc($r)){
$cadena = '<option value="'.$row["ID"].'">'.$row["Name"].'</option>';
array_push($respuesta,$cadena);
}
}
}
echo json_encode($respuesta);
?>