Instead of using ajax for return, I'm seeing the jQuery function $.post
or $.get
.
But I can only return one column of the mysql table with an echo. ex.
echo $conteudo['id'];
With ajax playing the return coming from the select (which can contain multiple lines) set everything from the array and just get in the answer .. echo json_encode($array);
How can I return an array that can contain multiple rows and get the function $.post
or $.get
?
ex.
$("#idInp").keyup(function(){
var idd = $("#idInp").val();
$.post('verifica.php',{id:idd},function(resposta){
$("#tex").empty();
if(resposta.trim() == $("#idInp").val() ){
$("#tex").append("nomes iguais");
}else{
$("#tex").append("nomes diferentes");
}
});
});
$seg = $pdo->prepare("SELECT * FROM usuarios WHERE name = :id");
$seg->bindValue(":id",$_POST['id']);
$seg->execute();
$v = $seg->fetch(PDO::FETCH_ASSOC);
echo $v['name'];
If I return only one line (echo $ name ['name']) will work, what if I have 100 lines? How can I do the same as ajax .. mount a loop and go through resposta[cont].name
.. resposta[cont].idade
.. anyway ..