0
I have in a database data page inserted in a table:
<div class="procurar">
<input type="text" id="search" onkeypress="mandar()"><i class="fa fa-search" aria-hidden="true"></i>
</div>
<div class="historico">
<table class="table" id="dados_entradas">
<?
$historico = mysql_query("SELECT ut.nome, ut.contribuinte, en.id_ficha, DATE_FORMAT(en.data_entrada,'%d-%m-%Y') as data
FROM entrada en,utilizador ut
WHERE en.contribuinte = ut.contribuinte");
while($linhas = mysql_fetch_array($historico))
{
?>
<tr>
<td style="width:25%;"><?echo $linhas['nome']; ?></td>
<td style="width:25%;"><?echo $linhas['contribuinte']; ?> </td>
<td style="width:25%;"><?echo $linhas['id_ficha']; ?> </td>
<td style="width:25%;"><?echo $linhas['data']; ?></td>
</tr>
<?
}
?>
</table>
And then I did an input with onkeypress to send in AJAX a query, to send to this same table.
AJAX
function mandar()
{
var search=$("#search").val();
$.post("dados-entradas.php",{search:search}, function(data){
$("#dados_entradas").html(data);
});
}
And on the page dados-entradas.php
$search = $_POST['search'];
$historico = mysql_query("SELECT ut.nome, ut.contribuinte, en.id_ficha, DATE_FORMAT(en.data_entrada,'%d-%m-%Y') as data
FROM entrada en,utilizador ut
WHERE en.contribuinte = ut.contribuinte
AND ut.nome = '$search'");
while($linhas = mysql_fetch_array($historico))
{
echo"<table class='table' id='dados_entradas'>
<tr>
<td style='width:25%;'>".$linhas['nome']."</td>
<td style='width:25%;'>".$linhas['contribuinte']."</td>
<td style='width:25%;'>".$linhas['id_ficha']."</td>
<td style='width:25%;'>".$linhas['data']."</td>
</tr>
</table>";
}
The problem is that it does not return any value, and defaces the entire home page except the table.