db_con.php
Código PHP:
<?
$host="localhost"; // Host name
$username="xxxxxx"; // Mysql username
$password="xxxxxx"; // Mysql password
$db_name="xxxxxxx"; // Database name
$tbl_name="like"; // Table name
?>
Código PHP:
<?php
include('db_con.php');
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name") or die ('Error al seleccionar la Base de Datos: '.mysql_error());
if($search)
{
$search = $_POST['search'];
$res = mysql_query("SELECT * FROM `like` WHERE `id` "%$search%"");
if (!$res)
echo "No se pudo realizar la búsqueda";
else
{
$comp = mysql_num_rows($res);
if($comp > 0)
{
echo "<b>Hay ".$comp." Resultado(s).</b>";
echo "<table border='0' width='450'>";
$c=1;
while($pru = mysql_fetch_array($res))
{
if($c%2==0)
$color="afcbd9";
else
$color="ffffff";
echo "<tr bgcolor=".$color." style='text-align:left;font-weight:bold;'><td> ".$c."<br> Clave: ".$pru."</td></tr>";
$c++;
}
echo "</table>";
}
else
echo "<b>No hay registros con ese término</b>";
}
}
?>
<table width="400"><tr><td>
<form id="buscar" name="buscar" method="post" action="">
<p>Termino de Consulta:
<input type="text" name="search" id="search" />
<input type="submit" name="Submit" value="Consultar" />
</p>
</form>
</td></tr></table>