0
alterar.php
<script type='text/javascript'>
$(document).ready(function(){
$("input[name='id']").blur(function(){
var $serialnum = $("input[name='serialnum']");
var $validadedata = $("input[name='validadedata']");
var $descr = $("input[name='descr']");
$.getJSON('function.php',{
id: $( this ).val()
},function( json ){
$serialnum.val( json.serialnum );
$validadedata.val( json.validadedata );
$descr.val( json.descr );
});
});
});
</script>
function.php
function retorna($id, $conn){
$result_aluno = "SELECT * FROM serialnumbers2 WHERE id = '$id'";
$resultado_aluno = mysqli_query($conn, $result_aluno);
if($resultado_aluno->num){
$row_aluno = mysqli_fetch_assoc($resultado_aluno);
$valores['serialnum'] = $row_aluno['serialnum'];
$valores['validadedata'] = $row_aluno['validadedata'];
$valores['descr'] = $row_aluno['descr'];
}else{
$valores['serialnum'] = 'Serial não existe';
$valores['validadedata'] = 'Serial não existe';
$valores[''] = 'Serial não existe';
}
}
Everything works with the serialnum and the expiration date, because when I put the id it will get these 2 automatically, but it does not bring the descending, and also everything is the same, someone knows why not go to the comic book?
I think we’re missing code, so we can help you, for example, where is your connection? and
return encode_json
in your role? Please post all the code so we can help you better.– William
The connection to Bd is correct, the problem has to be in these lines of code
– Fabrício Fonseca
So @April-March I posted below a reply where at the end of the
function retorna
, he returns a responsejson
, see if it helps you.– William