<?php
require_once("conexion/conexion.php");
$sql="select count(*) as cuantos from productos
where
titulo like '%".$_GET["s"]."%'
or
subtitulo like '%".$_GET["s"]."%'
or
img like '%".$_GET["s"]."%'
";
$res=mysql_query($sql,$con);
if ($reg=mysql_fetch_array($res))
{
$total=$reg["cuantos"];
}
$resto=$total % 5;
$ultimo=$total-$resto;
//****************************************************************
if (isset($_GET["pos"]))
{
$inicio=$_GET["pos"];
}else
{
$inicio=0;
}
$sql="select * from productos
where
titulo like '%".$_GET["s"]."%'
or
subtitulo like '%".$_GET["s"]."%'
or
img like '%".$_GET["s"]."%'
limit $inicio,5
";
$res=mysql_query($sql,$con);
?>
<html>
<head>
<title>Buscador</title>
<style type="text/css">
#principal{ width:800px; height:100%}
#header{ width:800px; height:100px; float:left; background-color:#666666; color:#FFFFFF}
#menu{ width:800px; height:25px; float:left}
.boton{ width:100px; height:25px; float:left; background-color:#FF0000; color:#FFFFFF}
.buscador{ width:300px; height:25px; float:left}
#main{ width:800px; height:100%; float:left}
</style>
</head>
<body>
<div id="principal">
<div align="center" id="header">
<h1>
cabecero
</h1>
</div>
<div id="menu">
<div class="boton">
boton 1
</div>
<div class="boton">
boton 1
</div>
<div class="boton">
boton 1
</div>
<div class="boton">
boton 1
</div>
<div class="boton">
boton 1
</div>
<!--acá va el div menu-->
<div align="center" class="buscador">
<form name="buscador" method="get" action="resultados.php">
<input type="text" name="s">
<input type="submit" name="search">
</a>
</form>
</div>
<!--acá va el div menu-->
</div>
<div align="center" id="main">
<table align="center" width="500">
<tr>
<td valign="top" align="center" width="500" colspan="3">
<h3>Resultados de su búsqueda</h3>
</td>
</tr>
<tr style="background-color:#666666; color:#FFFFFF; font-weight:bold">
<td valign="top" align="center" width="100">
Título
</td>
<td valign="top" align="center" width="300">
Detalle
</td>
<td valign="top" align="center" width="100">
Autor
</td>
</tr>
<?php
if (mysql_num_rows($res)==0)
{
?>
<tr>
<td valign="top" align="center" width="500" colspan="3" style="background-color:#f0f0f0">
No hay registros para ese criterio de búsqueda
</td>
</tr>
<?php
}else
{
$impresos=0;
while ($reg=mysql_fetch_array($res))
{
$impresos++;
?>
<tr style="background-color:#f0f0f0">
<td valign="top" align="center" width="100">
<?php echo chao_tilde(str_replace("".$_GET["s"]."","<b>".$_GET["s"]."</b>",$reg["titulo"]));?>
</td>
<td valign="top" align="center" width="300">
<?php echo chao_tilde(str_replace("".$_GET["s"]."","<b>".$_GET["s"]."</b>",$reg["subtitulo"]));?>
</td>
<td valign="top" align="center" width="100">
<?php echo '<img src="'.$reg['nombre'].'" id="picture" alt="vista previa" height="100" width="100"/>';?>
</td>
</tr>
<?php
}
}
?>
<tr>
<td valign="top" align="center" width="500" colspan="3">
<hr>
<!--*************************************-->
<?php
if (!$inicio==0)
{
?>
<a href="resultados.php?s=<?php echo $_GET["s"]?>&pos=0" title="Primero">Primero</a>
<?php
}else
{
?>
Primero
<?php
}
?>
<!--*************************************-->
<?php
if ($inicio==0)
{
?>
Anterior
<?php
}else
{
?>
<a href="resultados.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $inicio-5;?>" title="Anterior">Anterior</a>
<?php
}
?>
<!--*************************************-->
<?php
if ($impresos==5)
{
?>
<a href="resultados.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $inicio+5;?>" title="Siguientes">Siguiente</a>
<?php
}else
{
?>
Siguientes
<?php
}
?>
<!--*************************************-->
<?php
if ($inicio==$ultimo)
{
?>
Ultimo
<?php
}else
{
?>
<a href="resultados.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $ultimo;?>" title="Ultimo">Ultimo</a>
<?php
}
?>
<!--*************************************-->
</td>
</tr>
</table>
</div>
</div>
</body>
</html>