Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

ayuda con buscador

Estas en el tema de ayuda con buscador en el foro de Bases de Datos General en Foros del Web. -hola, necesitaria ayuda para un buscador php mysql que busca en una base de datos. el problema es que al entrar en la web muestra ...
  #1 (permalink)  
Antiguo 13/12/2010, 18:13
Avatar de alfoner  
Fecha de Ingreso: abril-2009
Mensajes: 146
Antigüedad: 15 años
Puntos: 0
Pregunta ayuda con buscador

-hola, necesitaria ayuda para un buscador php mysql que busca en una base de datos. el problema es que al entrar en la web muestra todos los resultados encontrados en la base de datos pero cuando le doy a buscar no hace nada...ayudaaa graicas

aqui esta el codigo
------------------------------------------------------------------------------------

include("conexion.php");

if ($_REQUEST["btnbuscar"]!="" && $_REQUEST["busqueda"]!="")
{
if (is_numeric($_REQUEST["busqueda"]))
$filtro=" and telefono=". $_REQUEST["busqueda"];
else
$filtro=" and nombre like '%".$_REQUEST["busqueda"]."%'";
} else {
$mensaje="<font color='red'>Por favor escriba algo en el cuadro de busqueda</font>";

}


$rst_clientes=mysql_query("SELECT * FROM clientes ORDER BY nombre ".$filtro.";",$conexion);
$num_registros=mysql_num_rows($rst_clientes);
if ($num_registros==0)
{
echo "No se han encontrado clientes";
mysql_close($conexion);
exit();
}
$registros=5;
$pagina=$_GET["num"];
if (is_numeric($pagina))
$inicio=(($pagina-1)*$registros);
else
$inicio=0;
$rst_clientes=mysql_query("SELECT * FROM clientes ORDER BY nombre $filtro LIMIT $inicio,$registros;",$conexion);
$paginas=ceil($num_registros/$registros);
?>
<div id="subheader">
<div class="padding">
<h2>Busqueda de datos de clientes</h2>
Escribe la &quot;LOCALIDAD&quot; de el cliente que necesites conocer sus datos y recibiras toda la información de los clientes de esa localidad.</div>
</div>
<table width="787" border="0">
<tr>
<td width="24"></td>
<td width="70"><form id="form1" name="form1" method="post" action="index.php">
<input type="submit" name="button" id="button" value="Volver" />
</form></td>
<td width="654"><form id="form2" name="form2" method="get" action="buscar.php">
Buscar
<input name="busqueda" type="text" id="busqueda" value="<?php echo $_GET["busqueda"];?>" />
<input type="submit" name="btnbuscar" id="btnbuscar" value="Buscar" />
<?php echo $mensaje; ?>
</form></td>
<td width="21">&nbsp;</td>
</tr>
</table>
<table width="788" border="0">
<tr>
<td width="20">&nbsp;</td>
<td width="732"><p>
<?php while ($fila = mysql_fetch_array($rst_clientes)) { ?>
</p>
<table width="724" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="724"><table width="721" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="12" bgcolor="#FF6600">&nbsp;</td>
<td width="663" bgcolor="#FF6600"><b><font color='white'><?php echo $fila["localidad"];?></b></td>
<td width="18"><a href="clientemodificar.php?tlf=<?php echo $fila["telefono"];?>"><img src="images/Icono_Escribir.png" alt="" width="14" height="15" border="0" align="right" /></a></td>
<td width="28"><a href="seguroeliminar.php?tlf=<?php echo $fila["telefono"];?>"><img src="images/Papelera.gif" width="22" height="20" border="0" align="right" /></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="729" border="0">
<tr>
<td width="46" bgcolor="#FFFFFF"><b>Nombre:</b></td>
<td width="316"><?php echo $fila["nombre"];?></td>
<td width="25" bgcolor="#FFFFFF"><b>DNI:</b></td>
<td width="106"><?php echo $fila["dni"];?></td>
<td width="50" bgcolor="#FFFFFF"><b>Telefono:</b></td>
<td width="160"><?php echo $fila["telefono"];?></td>
</tr>
</table>
<table width="728" border="0">
<tr>
<td width="57" bgcolor="#FFFFFF"><b>Localidad:</b></td>
<td width="135"><?php echo $fila["localidad"];?></td>
<td width="56" bgcolor="#FFFFFF"><b>Direccion:</b></td>
<td width="164"><?php echo $fila["direccion"];?></td>
<td width="85" bgcolor="#FFFFFF"><b>Establecimiento:</b></td>
<td width="205"><?php echo $fila["establecimiento"];?></td>
</tr>
</table>
<table width="728" border="0">
<tr>
<td width="93" bgcolor="#FFFFFF"><b>Observaciones:</b></td>
<td width="625"><font color='red'><b><?php echo $fila["observaciones"];?></b></td>
</tr>
</table></td>
</tr>
<p>&nbsp;</p>
<?php
}
?>
</table></td>
<td width="22">&nbsp;</td>
</tr>

</table>


<td width="19"></td>

<p>
</p>
<table width="788" border="0">
<tr>
<td>&nbsp;</td>
<td align="center">
<?php
if ($pagina>1)
echo "<a href='buscar.php?num=". ($pagina-1)."' >Anterior</a> ";
for ($cont=1;$cont<=$paginas;$cont++)
{
if ($cont==$pagina)
echo $cont." ";
else
echo "<a href='buscar.php?num=". $cont."' >$cont</a> ";
}
if ($pagina<$paginas)
echo "<a href='buscar.php?num=". ($pagina+1)."' >Siguiente</a> ";


?>
</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp; </p>
<p>
</td>
</p>
</p>
<div id="main">
<p>&nbsp;</p>
</div>
<div id="footer"></div>
</div>
</body>

</html>

Etiquetas: buscadores
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:51.