Código PHP:
<?php
class Buscador {
var $host='127.0.0.1',$user='root',$pass='cefierros',$db='licencias',$c_Servidor='Seconecto',$i_Servidor='no se conecto',$c_DB='selecciono la db',$i_DB='no selecciona DB';
function Conectar() {
if (!@mysql_connect($this->host,$this->user,$this->pass)){
print $this->i_Servidor;
}else{
if(!@mysql_select_db($this->db)){
print $this->i_DB;
}
}
}
function Buscar($q) {
$query = mysql_query("SELECT * FROM clientes where nombre LIKE '%$q%'");
if (mysql_num_rows($query)<=0){
print 'No se encontro ningun resultado';
} else {
echo "<table class='distabla' width='100%' border='1' cellspacing='0' cellpadding='0' >";
echo "<tr>
<th>Idcliente</th>
<th>Nombre</th>
<th>Domicilio</th>
</tr>";
while ($row = mysql_fetch_assoc($query)) {
//echo "<tr onclick=\"document.getElementById('idclient').value=$row[idcliente];\">
echo "<tr onclick=\"document.getElementById('idclient').value=$row[idcliente];
document.getElementById('nombre').value=$row[nombre];
\">
<td>".$row['idcliente']."</td>";
echo "<td>".$row['nombre']."</td>";
echo "<td>".$row['domicilio']."</td>
</tr>";
}
echo '</table>';
}
}
}
?>