Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/03/2013, 12:24
Avatar de evolutionrgm
evolutionrgm
 
Fecha de Ingreso: mayo-2011
Mensajes: 108
Antigüedad: 13 años
Puntos: 5
Respuesta: Problema formulario

mira te dejare un codigo de una agenda que hice utilice busqueda muy similar a lo que tu necesitas .. obviamente tu la tendras que dejar dentro de un form espero que te sirva

Código PHP:
Ver original
  1. <?php
  2. include 'conexion.php';
  3. conectar();
  4. ?>
  5.  
  6.  
  7.  
  8.  <form id="form" name="form" method="post" action="agenda.php">
  9.       <h1>Agenda On Line </h1>
  10.       <p>Ingrese un Parametro para Consultar</p>
  11.       <p>
  12.         <label>Nombre o Ocupacion<span class="small">Ingr a lo menos 3 letras</span> </label>
  13.         <input type="text" name="dato" id="dato" />
  14.         <label>Dpto Desempe&ntilde;o<span class="small">Dpto de Funciones</span> </label>
  15.         <select name="depto" id="depto">
  16.         <option value="0">Depto Funciones </option>
  17.           <?php
  18. $consul=mysql_query("SELECT * FROM t_dpto");
  19. while($registro=mysql_fetch_row($consul))
  20. {    
  21.          echo "<option value='$registro[0]''$registro[1]'>$registro[1]</option>";  
  22.     }
  23. ?>
  24.         </select>    
  25.       </p>
  26.       <button type="submit" name="buscar">Buscar</button>
  27.       <div class="spacer"></div>
  28.     </form>
  29.   </div>
  30. </div>
  31. <?
  32.  
  33.     if (isset($_POST['buscar'])){
  34.         //paso las Variables a metodo POST
  35.         $dato=$_POST['dato'];
  36.         $depto=$_POST['depto'];
  37. ?>
  38. <div id="apDiv8">
  39. <table width="839" border="0" cellspacing="0" cellpadding="0">
  40.   <tr>
  41.     <th width="136">Nombre</th>
  42.     <th width="104">Cargo</th>
  43.     <th width="70">Anexo</th>
  44.     <th width="103">Celular</th>
  45.     <th width="91">Red Fija</th>
  46.     <th width="96">E-M@il</th>
  47.   </tr>
  48.   <?php
  49.  
  50.  $consul=mysql_query("SELECT * FROM t_agenda where nombre like '%$dato%' or id_dpto ='$depto' ");
  51. while($reg=mysql_fetch_assoc($consul))
  52. {
  53.    
  54. ?>
  55.   <tr>
  56.     <td><?php echo $reg['nombre'] ?></td>
  57.     <td><?php echo $reg['cargo'] ?></td>
  58.     <td><?php echo $reg['anexo'] ?></td>
  59.     <td><?php echo $reg['celular'] ?></td>
  60.     <td><?php echo $reg['fono'] ?></td>
  61.     <td><?php echo $reg['mail'] ?></td>
  62.   </tr>
  63.  <?php }}  ?>
  64. </table>