Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/11/2010, 04:30
Avatar de DiegoAH
DiegoAH
 
Fecha de Ingreso: noviembre-2010
Ubicación: Madrid
Mensajes: 53
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Mandar un valor nulo

EL formulario esta en el div con id="introducir"

Código HTML:
Ver original
  1.     <head>
  2. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  3.         <script type="text/javascript">
  4.             function getdatos(value){
  5.                 $.post("getdatos.php", {partialdato:value}, function(data){
  6.                     $("#results").html(data);
  7.             });
  8.             }
  9.            
  10.        
  11.         </script>
  12.    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  13.        <style type:="text/css">
  14.     body {
  15.     font-style:italic;
  16.     margin: 0 auto;
  17.     font-family: arial;
  18.     text-align:center;
  19.     background-color: #F0F0F0;
  20.     vertical-align:center;
  21.     background-image:url(fondo-cabecera.png);
  22.     background-repeat:repeat-x;
  23.         }
  24.     table.fija{table-layout: fixed}
  25.        
  26.     #cabecera{
  27.     background-color:#000;
  28.     background-repeat:repeat;
  29.     margin-top:40px;
  30.     margin-bottom:60px
  31.    
  32.    
  33.             }
  34.             #introducir{
  35.                 margin-top:60px;
  36.                 margin-bottom:20px;
  37.                 border:solid 9px #626262;
  38.                 width:950px;
  39.            
  40.             }
  41.    
  42.     #tabla1{
  43.     font-weight: bold;
  44.     color: #F0F0F0;
  45.     height:auto;
  46.     width:auto;
  47.     overflow: hidden;
  48.     class="fija";
  49.     font-family: Arial;
  50.     font-size: 20px;
  51.     font-style: normal;
  52.     line-height: normal;
  53.     text-transform: capitalize;
  54.  
  55.         }
  56.        
  57.         #parte2{
  58.     background-color: #F0F0F0;
  59.     color:#000000;
  60.         }
  61.    
  62.        
  63.         #tabla1 .fija {
  64.     color: #FF0000;
  65. }
  66. #busqueda{
  67.     color:#CCCCCC;
  68.     text-align: left;
  69.     font-family: georgia;
  70.     font-size:14px;
  71.     font-style:italic;
  72.     margin-bottom:30px;
  73.    
  74. }
  75.  
  76.  
  77. #busqueda2{
  78.     font-family:Georgia;
  79.     font-style:italic;
  80.     font-size: 56px;
  81.     color: #CCC;
  82.     background-color: #F0F0F0; 
  83.     }
  84.    
  85.     #general{
  86.             width:960px;
  87.             margin: 0 auto;
  88.                 }
  89.  
  90.      #columanas_principales {
  91.          
  92.          font-family: Arial;
  93.          font-weight:bold;
  94.          font-size:14px;
  95.          color: #000;
  96.          
  97.          }
  98.          
  99.       p {
  100.          
  101.           font-family: Arial;
  102.           font-size: 12px;
  103.           font-weight:normal;
  104.          
  105.           }
  106.      
  107.      .lupa{
  108.         background: white url(lupa.png) no-repeat 866px center;
  109.                         width:950px;
  110.  
  111.    
  112.      }
  113.      
  114.     #barra{
  115.     background-repeat:repeat;
  116.     background-image: url(BARRA-INFERIOR.jpg);
  117.      }
  118.      
  119.     #results{
  120.         font-family:arial;
  121.         font-size:12px;
  122.         color:#000;
  123.         line-height:120%;
  124.         margin-top:-40px;
  125.         margin-bottom:10px;
  126.         }
  127.        
  128.          
  129.       .par{
  130.    
  131.            background-color:#CCC;  
  132.       }
  133.        
  134.       .impar{
  135.    
  136.            background-color:#F0F0F0;
  137.            
  138.       }
  139.      .centrado{
  140.          text-align:left;
  141.          font-family:arial;
  142.          font-size:14px;
  143.          font-weight:bold;
  144.          width:60px;
  145.          padding-left:12px;
  146.        
  147.          
  148.      }
  149.      .nombre{
  150.          font-family:arial;
  151.          font-size:14px;
  152.          font-weight:bold;
  153.          height:44px;
  154.          width:300px;
  155.          padding-left:12px;
  156.          
  157.        
  158.        
  159.      }
  160.      .mail{
  161.                  width:260px;
  162.                  padding-left:12px;
  163.  
  164.      }
  165.      .departamento{
  166.           width:160px;
  167.           padding-left:12px;
  168.      }
  169.    
  170.         </style>
  171.        
  172.      
  173.        
  174. </head>
  175.    
  176.    
  177.  
  178.  
  179. <div id="general">
  180. <div id="cabecera">
  181.   <div id="logoied" align="right"><img src="logo-izq.png" width="127" height="25" alt="buscar" align="left" />
  182.     <img src="logo-ied2.png" width="70" height="32" alt="buscar" />
  183.    
  184.   </div>
  185. <div id="introducir">
  186.     <input name="campo" type="text" class="lupa" id="busqueda2" onKeyUp="getdatos(this.value)"  size="32"  alt="busca por nombre o email" >
  187. </div>
  188. <div id="busqueda">
  189. <img src="ojo2.png" width="25" height="17" alt="buscar" />
  190. B&uacute;scame por mi nombre, mail, o departamento</br></div></br>
  191. <div class="fija" id="tabla1">
  192.  
  193. <table width="960" height="26" class="fija" >
  194.     <tr align="left">
  195. <td width="300" height="20">Nombre</td>
  196. <td width="260">Mail</td>
  197. <td width="160" >Departamento</td>
  198. <td width="60" class="centrado">Ext.</td>
  199. </tr>
  200.    
  201.   </table>
  202. </div>
  203.  
  204. </div>
  205.  
  206.  
  207. <table id="results"width="960" height="24" class="fija" >
  208. <td width="960"></tr>
  209.    
  210.   </table>
  211.  
  212.     <div id="barra">
  213.     <img src="BARRA-INFERIOR.jpg" width="1" height="2" alt="buscar" />
  214.     </div>
  215.  
  216.     <p align="right"><img src="logoizqabajo.png" width="95" height="15" alt="buscar" align="left"/><img src="logodrchabajo.png" width="61" height="28" alt="buscar" /></p>
  217.   <img src="derechos.png" width="191" height="9" alt="buscar" align="left" style="margin-top:-20px"/>
  218. </div>
  219. </div>
  220.  
  221. </body>
  222. </html>

Código PHP:
Ver original
  1. <?php
  2. mysql_connect("localhost", "root", "") or die(mysql_error());
  3. mysql_select_db("busqueda") or die(mysql_error());
  4. header('Content-Type: text/html; charset=ISO-8859-1');
  5. $partialdatos = $_POST['partialdato'];
  6. $datos= mysql_query("SELECT * from datos where todo LIKE '%$partialdatos%'");  
  7.  
  8.          
  9.                
  10.         while($dato= mysql_fetch_array($datos)){
  11.          
  12.         if ($impar)
  13.         {
  14.    
  15.                 echo '<tr class="impar"><td class="nombre">'.$dato['nombre_apellido'].'</td>';
  16.                 echo '<td class="mail" >'.$dato['email'].'</td>';
  17.                 echo '<td class="departamento">'.$dato['departamento'].'</td>';
  18.                 echo '<td class="centrado">'.$dato['extension'].'</td></tr>';
  19.                 $impar = false;
  20.         }
  21.         else
  22.         {
  23.             echo '<tr class="par"><td class="nombre">'.$dato['nombre_apellido'].'</td>';
  24.                 echo '<td class="mail">'.$dato['email'].'</td>';
  25.                 echo '<td class="departamento">'.$dato['departamento'].'</td>';
  26.                 echo '<td class="centrado">'.$dato['extension'].'</td></tr>';
  27.                 $impar = true;
  28.         }
  29.  
  30.     }  
  31. ?>