I need to make an sql query with the results of an array so that it picks up some specific bbdd values
var array_ch=JSON.stringify(ar);
$.ajax({
url:'php/ch.php',
type:'POST',
data:{ch:array_ch},//aqui esta el array que yo envio con los valores devueltos con un checkbox
success:function(resp){
console.log(resp);
},
error:function(error){
console.log(error);
}
});
Query:
$data = json_decode(stripslashes($_POST['ch']));
$sql="SELECT * FROM hotel WHERE estrellas='$data' ";
$consulta=mysqli_query($con,$sql);
while ($row1=mysqli_fetch_assoc($consulta)){
$data1[]=$row1;
}
echo json_encode($data1);
I need to receive results according to the stars that the user specifies any ideas? thanks