Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/04/2014, 22:00
cdisenia
 
Fecha de Ingreso: junio-2012
Mensajes: 30
Antigüedad: 11 años, 11 meses
Puntos: 0
Problema con buscador de noticia no muestra resultado

Buenas al foro, necesito la ayuda del foro nuevamente resulta que me pasaron un buscador en php, yo lo he modificado para que me busque los titulos de las noticias de mi base de datos, pero resulta que no me busca las noticias y me devuelve todo vacio, les paso los codigos:

Esta es la base de datos:

Código SQL:
Ver original
  1. `id` INT(1) NOT NULL AUTO_INCREMENT,
  2.   `titulo` VARCHAR(255) NOT NULL DEFAULT '',
  3.   `subtitulo` text NOT NULL,
  4.   `detalle` text NOT NULL,
  5.   `fuente` VARCHAR(255) NOT NULL DEFAULT '',
  6.   `foto` VARCHAR(140) NOT NULL DEFAULT '',
  7.   `fecha` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  8.   PRIMARY KEY  (`id`)

Este es el campo form:

Código PHP:
Ver original
  1. <form name="buscador" method="get" action="administrador/buscar.php" >
  2. <input type="text" name="s" class="busca1">
  3. <a href="javascript:void(0)" title="Buscar" onClick="document.buscador.submit();">
  4. <img src="imagenes/lupa.png" width="24" height="24" border="0">
  5. </a>
  6. </form>

Este es el archivo buscar.php y no me devuelve ningún resultado de la busqueda

Código PHP:
Ver original
  1. <?php
  2. require '../conexion/conexion.php';
  3. $sql="select count(*) as cuantos from noticia
  4. where
  5. titulo like '%".$_GET["s"]."%'";
  6. $res=mysql_query($sql,$con);
  7. if ($reg=mysql_fetch_array($res))
  8. {
  9.     $total=$reg["cuantos"];
  10. }
  11. $resto=$total % 5;
  12. $ultimo=$total-$resto;
  13.  
  14. //****************************************************************
  15. if (isset($_GET["pos"]))
  16. {
  17.     $inicio=$_GET["pos"];
  18. }else
  19. {
  20.     $inicio=0;
  21. }
  22. $sql="select * from noticia
  23. where
  24. titulo like '%".$_GET["s"]."%'
  25. limit $inicio,5
  26. ";
  27. $res=mysql_query($sql,$con);
  28.  
  29. ?>
  30.  
  31. <table align="center" width="100%">
  32. <tr>
  33. <td valign="top" align="center" width="100%" colspan="3">
  34. <h3>Resultados de su b&uacute;squeda</h3>
  35. </td>
  36. </tr>
  37.  
  38. <tr style="background-color:#666666; color:#FFFFFF; font-weight:bold">
  39. <td valign="top" align="center" width="100%">
  40. Título
  41. </td>
  42. </tr>
  43. <?php
  44. if (mysql_num_rows($res)==0)
  45.  
  46. {
  47.     ?>
  48.     <tr>
  49.     <td valign="top" align="center" width="100%" colspan="3" style="background-color:#f0f0f0">
  50.     No hay registros para ese criterio de b&uacute;squeda
  51.     </td>
  52.     </tr>
  53.     <?php
  54. }else
  55. {
  56.  
  57. $impresos=0;
  58. while ($reg=mysql_fetch_array($res))
  59. {
  60. $impresos++;
  61. ?>
  62. <tr style="background-color:#f0f0f0">
  63. <td valign="top" align="center" width="100%">
  64. <p><?php echo $res["titulo"]; ?></p>
  65. </td>
  66. </tr>
  67. <?php
  68. }
  69. }
  70. ?>
  71. <tr>
  72. <td valign="top" align="center" width="500" colspan="3">
  73. <hr>
  74. <?php
  75. if (!$inicio==0)
  76. {
  77.     ?>
  78.     <a href="buscar.php?s=<?php echo $_GET["s"]?>&pos=0" title="Primero">Primero</a>
  79.     <?php
  80. }else
  81. {
  82.     ?>
  83.     Primero
  84.     <?php
  85. }
  86. ?>
  87. <?php
  88. if ($inicio==0)
  89. {
  90.     ?>
  91.     Anterior
  92.     <?php
  93. }else
  94. {
  95.     ?>
  96.     <a href="buscar.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $inicio-5;?>" title="Anterior">Anterior</a>
  97.     <?php
  98. }
  99. ?>
  100.  
  101. <?php
  102. if ($impresos==5)
  103. {
  104.     ?>
  105.     <a href="buscar.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $inicio+5;?>" title="Siguientes">Siguiente</a>
  106.     <?php
  107. }else
  108. {
  109.     ?>
  110.     Siguientes
  111.     <?php
  112. }
  113. ?>
  114.  
  115. <?php
  116. if ($inicio==$ultimo)
  117. {
  118.     ?>
  119.     Ultimo
  120.     <?php
  121. }else
  122. {
  123. ?>
  124. <a href="buscar.php?s=<?php echo $_GET["s"]?>&pos=<?php echo $ultimo;?>" title="Ultimo">Ultimo</a>
  125. <?php
  126. }
  127. ?>
  128.  
  129. </td>
  130. </tr>
  131.  
  132. </table>

Desde ya muchas gracias por ayudarme.