Ver Mensaje Individual
  #12 (permalink)  
Antiguo 05/10/2010, 15:07
zapt142
 
Fecha de Ingreso: julio-2010
Ubicación: La Ciudad Blanca, Mérida-Yucatán
Mensajes: 375
Antigüedad: 13 años, 9 meses
Puntos: 7
Respuesta: Busqueda por medio de combobox

he modificado mi codigo del form, de tal forma que ya no necesito un boton del tipo submit para enviar el form sino que el evento onchange del combobox lo envie bueno aqui esta mi codigo:

Código PHP:
Ver original
  1. <?php
  2. include('config.php');
  3. $query = "select count(*) as suma from noticias where mes = '$mes' and anio = '$ano'";
  4.                       $res = mysql_query($query,$conn) or die(mysql_error());
  5.                       $fila = mysql_fetch_array($res);
  6.                       $filas_pagina = 15;
  7.                        $numpaginas = ceil($fila['suma']/$filas_pagina);
  8.  
  9. if(isset($_REQUEST['pagina']))
  10. {
  11.     $pagina=$_REQUEST['pagina'];
  12. }
  13. else
  14. {
  15.     $pagina = 1;
  16. }
  17.                     $sql = "select * from noticias where mes = '$mes' and anio = '$ano' limit ".(($pagina-1)*$filas_pagina).",".$filas_pagina;
  18.                                    
  19. ?>
  20. <html>
  21. <head>
  22. <title>Noticias</title>
  23. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  24. <style type="text/css">
  25. <!--
  26. body {
  27.     background-image: url(images/fondoadmin.jpg);
  28.     background-repeat: repeat-x;
  29. }
  30. -->
  31. </style>
  32. <link href="file:///C|/wamp/www/el faroadmin/text.css" rel="stylesheet" type="text/css">
  33. </script>
  34. </head>
  35. <body bgcolor="#EBEBDC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  36. <!-- ImageReady Slices (elfaro_administrador.psd) -->
  37. <table width="1100" height="210" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
  38. <tr>
  39.         <td height="121" valign="top">
  40.             <img src="images/elfaro_administrador_01.jpg" width="1100" height="121" alt=""></td>
  41.   </tr>
  42.     <tr>
  43.         <td height="26" valign="top">
  44.             <img src="images/botonesmenu/btnsnoticias.jpg" width="1100" height="26" alt=""></td>
  45.   </tr>
  46.     <tr>
  47.         <td width="1100" height="44" valign="top"><table width="1097" border="0" cellpadding="0" cellspacing="0">
  48.           <tr>
  49.             <td width="63" height="7"></td>
  50.             <td width="840"></td>
  51.             <td width="194"></td>
  52.           </tr>
  53.           <tr>
  54.             <td>&nbsp;</td>
  55.             <td class="texttituloseccion">:: <span class="Tituloseccion">Noticias</span></td>
  56.             <td><!--BTN DE AGREGAR --><img src="images/botones/agregarmas.jpg" width="121" height="24"></td>
  57.           </tr>
  58.         </table></td>
  59.   </tr>
  60.     <tr>
  61.         <td height="19" valign="top"><table width="1099" border="0" cellpadding="0" cellspacing="0">
  62.           <tr>
  63.             <td>&nbsp;</td>
  64.             <td></td>
  65.             <td>&nbsp;</td>
  66.           </tr>
  67.           <tr>
  68.             <td>&nbsp;</td>
  69.             <td class="general">Filtrar por seccion Perteneciente: <form name="form" action="noticias.php" method="post"><select name="busqueda" onChange="form.submit();">
  70.  
  71.  <option value="100">Ver Todas</option>
  72.             <?php
  73.             $ssql = "select * from seccion";
  74.             $ql = mysql_query($ssql,$conn) or die(mysql_error());
  75.             while($g = mysql_fetch_array($ql)){
  76.             if($g['seccion'] == 'noticias de campeche'){
  77. echo '<option value="'.$g['id_seccion'].'">Noticias De Campeche</option>';
  78. }
  79. if($g['seccion'] == 'espectaculos'){
  80. echo '<option value="'.$g['id_seccion'].'">Espectáculos</option>';
  81. }
  82. if($g['seccion'] == 'deportes'){
  83. echo '<option value="'.$g['id_seccion'].'">Deportes</option>';
  84. }
  85. if($g['seccion'] == 'mexico y el mundo'){
  86. echo '<option value="'.$g['id_seccion'].'">México y El Mundo</option>';
  87. }
  88. if($g['seccion'] == 'reportajes'){
  89. echo '<option value="'.$g['id_seccion'].'">Reportajes</option>';
  90. }
  91. if($g['seccion'] == 'mundo maya'){
  92. echo '<option value="'.$g['id_seccion'].'">Mundo Maya</option>';
  93. }
  94. if($g['seccion'] == 'lo insolito'){
  95. echo '<option value="'.$g['id_seccion'].'">Lo Insolito</option>';
  96. }
  97. if($g['seccion'] == 'eventos'){
  98. echo '<option value="'.$g['id_seccion'].'">Eventos</option>';
  99. }
  100. if($g['seccion'] == 'opinion'){
  101. echo '<option value="'.$g['id_seccion'].'">Opinión</option>';
  102. }
  103.             }
  104.             ?>
  105.             </select>
  106.            <!-- <input type="submit" name="as" value="Ir" />-->
  107.             </form></td>
  108.             <td>&nbsp;</td>
  109.           </tr>
  110.           <tr>
  111.             <td width="85" height="7"></td>
  112.             <td width="929"></td>
  113.             <td width="85"></td>
  114.           </tr>
  115.           <tr>
  116.             <td>&nbsp;</td>
  117.             <td><!--AQUI VAS A PONER TU INFO -->
  118.               <table width="928" height="49" border="0" cellpadding="0" cellspacing="0">
  119.                 <tr>
  120.                   <td><table width="929" border="0" cellpadding="0" cellspacing="1">
  121.                     <tr>
  122.                       <td width="19" bgcolor="dcedfd">&nbsp;</td>
  123.                       <td width="597" bgcolor="dcedfd" class="general">Selecione una noticia a editar</td>
  124.                       <td width="313" bgcolor="dcedfd" class="numerodetal"> &nbsp;Numero de Noticias Actuales:<?php            
  125.                       echo $fila['suma'];
  126.                       ?></td>
  127.                     </tr>
  128.                   </table></td>
  129.                 </tr>
  130.                 <tr>
  131.                   <td><table width="928" border="0" cellpadding="0" cellspacing="0">
  132.                     <tr>
  133.                       <td width="616" height="23" bgcolor="d8d8d8" class="titucolumnas"><div align="left">&nbsp;&nbsp;Nombre de Noticia</div></td>
  134.                       <td width="143" bgcolor="d8d8d8" class="titucolumnas"><div align="center">Secci&oacute;n</div></td>
  135.                       <td width="96" bgcolor="d8d8d8" class="titucolumnas"><div align="center">Publicada</div></td>
  136.                       <td width="73" bgcolor="d8d8d8" class="titucolumnas"><div align="center">Eliminar</div></td>
  137.                     </tr>
  138.                     <?php
  139.                     if($_POST['busqueda'] == 100){
  140.                     $sql = "select * from noticias where mes = '$mes' and anio = '$ano' limit ".(($pagina-1)*$filas_pagina).",".$filas_pagina; }
  141.                     if(($_POST['busqueda'] != 0) and ($_POST['busqueda'] != 100)){
  142.                     $query = "select count(*) as suma from noticias where mes = '$mes' and anio = '$ano' and seccion=".$_POST['busqueda'];
  143.                       $res = mysql_query($query,$conn) or die(mysql_error());
  144.                       $fila = mysql_fetch_array($res);
  145.                       $filas_pagina = 15;
  146.                        $numpaginas = ceil($fila['suma']/$filas_pagina);
  147.  
  148. if(isset($_REQUEST['pagina']))
  149. {
  150.     $pagina=$_REQUEST['pagina'];
  151. }
  152. else
  153. {
  154.     $pagina = 1;
  155. }
  156.                         $sql = "select * from noticias where mes = '$mes' and anio = '$ano' and seccion = ".$_POST['busqueda']." limit ".(($pagina-1)*$filas_pagina).",".$filas_pagina;
  157. }
  158.                     $result = mysql_query($sql,$conn) or die(mysql_error());
  159.                     while($row = mysql_fetch_array($result)){
  160.                     echo '<tr>';
  161.                     echo '<td><a href="edit_noticias.php?id_noticia='.$row['id_noticia'].'">'.$row['titulo'].'</a></td>';
  162.                     $do = "select * from seccion where id_seccion =".$row['seccion'];
  163.                     $done = mysql_query($do,$conn) or die(mysql_error());
  164.                     $a = mysql_fetch_array($done);
  165.                     if($a['seccion'] == 'noticias de campeche'){
  166. echo '<td align="center">Noticias De Campeche</td>';
  167. }
  168. if($a['seccion'] == 'espectaculos'){
  169. echo '<td align="center">Espectáculos</td>';
  170. }
  171. if($a['seccion'] == 'deportes'){
  172. echo '<td align="center">Deportes</td>';
  173. }
  174. if($a['seccion'] == 'mexico y el mundo'){
  175. echo '<td align="center">México y El Mundo</td>';
  176. }
  177. if($a['seccion'] == 'reportajes'){
  178. echo '<td align="center">Reportajes</td>';
  179. }
  180. if($a['seccion'] == 'mundo maya'){
  181. echo '<td align="center">Mundo Maya</td>';
  182. }
  183. if($a['seccion'] == 'lo insolito'){
  184. echo '<td align="center">Lo Insolito</td>';
  185. }
  186. if($a['seccion'] == 'eventos'){
  187. echo '<td align="center">Eventos</td>';
  188. }
  189. if($a['seccion'] == 'opinion'){
  190. echo '<td align="center">Opinión</td>';
  191. }
  192. echo '<td align="center">'.$row['publicada'].'</td>';
  193. echo '<td align="center"><a href="elim_noticia.php?id_noticia='.$row['id_noticia'].'"><img src="images/botones/eliminar.jpg" /></a></td>';
  194.                     echo '</tr>';
  195.                     }
  196.                     ?>
  197.                   </table>
  198.                   <?php
  199.                   echo '<table  cellspacing="3" height="50">';
  200. echo "<tr>";
  201.  
  202. if ($pagina!=1)
  203. {
  204. echo '<td class="nproduct"><strong><a href="noticias.php?pagina=1" style="color:#793f00; text-decoration:none"> << </a></strong></td>';
  205. echo '<td class="nproduct"><strong><a href="noticias.php?pagina='.($pagina-1).' "style="color:#793f00; text-decoration:none"> < </a></strong></td>';
  206. }
  207.  
  208. for($i=1;$i<=$numpaginas;$i++)
  209. {
  210.     $temp='';
  211.     if ($i==$pagina)
  212.         $temp=$i;
  213.     else
  214.         $temp='<a href="noticias.php?pagina='.$i.'" style="color:#000000; text-decoration:none">'.$i.'</a>';
  215.     echo '<td><strong>'.$temp.'</strong></td>'."\n";
  216. }
  217.  
  218. if ($pagina!=$numpaginas)
  219. {
  220.     echo '<td><strong><a href="noticias.php?pagina='.($pagina+1).'" style="color:#000000; text-decoration:none"> > </a></strong></td>';
  221.     echo '<td><strong><a href="noticias.php?pagina='.$numpaginas.'" style="color:#000000; text-decoration:none"> >> </a></strong></td>';
  222.  
  223. }
  224.  
  225. echo "</tr>";
  226. echo "</table>";
  227.  
  228.  
  229.                   ?></td>
  230.                 </tr>
  231.               </table></td>
  232.             <td>&nbsp;</td>
  233.           </tr>
  234.         </table></td>
  235.   </tr>
  236. </table>
  237. <!-- End ImageReady Slices -->
  238. </body>
  239. </html>

ahora mi duda es como hago para que me muestre todos otra vez ya que si elijo determinada sección funciona pero si elijo ver todas no me muestra todas,
gracias por tu tiempo, y tu orientación @egepe
__________________
--No todos aprendemos de la misma forma, ni a la misma velocidad---