My question is as follows, I have a table in MySQL
with id
, pesquisa
and data
. I want to give select
to this table in php
and return ajax
so that I can insert each element into a specific td
within a table
. How can I do this?
<div class="janelaLateral">
<table id="tdTeste" name="tableConteudoPesquisado" cellpadding="0" cellspacing="0">
<tr>
<td>id</td>
<td>Data</td>
<td>Pesquisa Realizada</td>
</tr>
</table>
</div>
function fImprimir(){
$.ajax({
url: "php/listarPesquisaRealizadaBanco.php",
type: "GET",
dataType: "json",
success:function(ret){
$("#tdTeste").append(ret);
}
});
}
$resultado = mysqli_query($conn, "SELECT * FROM tabelaProva");
$contador = 0;
while($row = mysqli_fetch_assoc($resultado)){
$retorno[$contador] = $row["id"];.$row["pesquisa"].$row["data"];
$contador++;
}
mysqli_close($conn);
echo json_encode($retorno);