Este es mi codigo html:
Código HTML:
<section> <table border="0" align="center"> <tr> <td width="335"><input type="text" placeholder="Search by company name" id="bs-prod" /></td> </tr> </table> </section>
Código PHP:
include('conexion.php');
$dato = $_POST['dato'];
//EJECUTAMOS LA CONSULTA DE BUSQUEDA
if ($dato == $_POST['dato']) {
$registro = pg_query($con, "SELECT cm.*, pgc.* FROM company_main cm, parent_group_catalog pgc where cm.parentgroup = pgc.groupID and cm.companyName like '%$dato%'");
//CREAMOS NUESTRA VISTA Y LA DEVOLVEMOS AL AJAX
echo '<table class="table table-striped table-condensed table-hover" id="ordCons">
<tr>
<th width="50">ID</th>
<th width="100">Company Name</th>
<th width="150">Activity Description</th>
<th width="150">Public or Private</th>
<th width="150">Address</th>
<th width="100">Parent Group</th>
<th width="50">Is Client</th>
<th width="50">Country</th>
<th width="50">GRP TaxID:</th>
<th width="50">Activities:</th>
<th width="50">Tax ID:</th>
</tr>';
if(pg_num_rows($registro)>0){
while($registro2 = pg_fetch_array($registro)){
echo '<tr>
<td>'.$registro2['0'].'</td>
<td>'.$registro2['1'].'</td>
<td>'.$registro2['6'].'</td>
<td>'.$registro2['8'].'</td>
<td>'.$registro2['9'].'</td>
<td>'.$registro2['14'].'</td>';
if ($registro2['10'] == 'true') {
echo "<td>Yes</td>";
}else{
echo "<td>No</td>";
}
echo ' <td>'.$registro2['5'].'</td>
<td>'.$registro2['16'].'</td>
<td>'.$registro2['18'].'</td>
<td>'.$registro2['3'].'</td>
</tr>';
}
}else{
echo '<tr>
<td colspan="6">There is not more records</td>
</tr>';
}
}elseif($dato == '') {
echo '<tr>
<td colspan="6">There is not more records</td>
</tr>';
}
echo '</table>';
y este es mi codigo javascript de la peticion ajax
Código:
Alguien que me pueda ayudar por favor. $(function() { $('#bs-prod').on('keyup', function() { var dato = $('#bs-prod').val(); var url = '../php/busca_registro.php'; $.ajax({ type: 'POST', url: url, data: 'dato=' + dato, success: function(datos) { $('#agrega-registros').html(datos); } }); return false; }); }); }