javascript - Pass input value array to php and use in MySQL SELECT -


i'm trying send hidden input json array value php , use in conditional mysql select:

my input looks like:

<input type="hidden" name="n_processo2" id="n_processo2" value="["203","1430"]"> 

my ajax:

$('input[name=ano]').on('change', function() {     var fabricante = $('select[name=fabricante]').val();     var seguimento = $('select[name=seguimento]').val();     var veiculo = $('select[name=veiculo]').val();     var motor = $('input[name=motor]').val();     var ano = $(this).val();      $.ajax({         method: 'post',         url: 'combo.php',         data:{opcao: 'ano', fabricante: fabricante, seguimento: seguimento, veiculo: veiculo, motor: motor, ano: ano},         datatype: 'json',         beforesend: function(){             $('#status').html('aguarde, buscando...');             $('div#conteudo').html('');         },         success: function(data){              $('input[name=n_processo2').val(data.processo2);              var fabricante = $('select[name=fabricante]').val();             var seguimento = $('select[name=seguimento]').val();             var veiculo = $('select[name=veiculo]').val();             var motor = $('input[name=motor]').val();             var ano = $('input[name=ano]').val();             var n_processo2 = $('input[name=n_processo2]').val();                  $.ajax({                     method: 'post',                     url: 'combo.php',                     data:{opcao: 'ano', fabricante: fabricante, seguimento: seguimento, veiculo: veiculo, motor: motor, ano: ano, n_processo2: json.stringify(n_processo2)},                     datatype: 'json',                     beforesend: function(){                         $('#status').html('aguarde, buscando...');                         $('div#conteudo').html('');                     },                         success: function(data){                         console.log("success:",data);                         $('#status').html('');                         $('div#conteudo').html(data.conteudo);                     }                 })         }     });          $("input[name=ano]").keydown(function (e){         if(e.keycode == 13){             $("input[name=ano]").blur();         }     }); }); 

and php/mysql code:

$jsondata = array(); $jsondata[] = $automovel->n_processo; $data['processo2'] .= json_encode($jsondata);  $ar2 = json_decode($processo2, true);                          $where2 = array();                             foreach ($ar2 $condition2) {                               $value2 = reset($condition2);                                 $column2 = key($condition2);                                  $where2[] = $value2;                              }                             $wherestring2 = implode(' , n_processo in ', $where2);                          $pegasonda = $pdo->prepare("select * sonda fabricante = '$fabricante' , modelo = '$veiculo' $wherestring2");                         $pegasonda->execute(); 

the problem when results, looks php not receiving correct data, can't find why. can please me please?


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -