sql query sent with an array from jquery

0

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

    
asked by adrian ruiz picazo 16.05.2018 в 23:42
source

0 answers