Ver Mensaje Individual
  #17 (permalink)  
Antiguo 20/03/2009, 13:04
Avatar de the_web_saint
the_web_saint
 
Fecha de Ingreso: mayo-2008
Ubicación: localhost/tierra/america/panama
Mensajes: 1.229
Antigüedad: 16 años
Puntos: 43
Respuesta: Pbroblemas con este buscar?

Formulario:

Código php:
Ver original
  1. <form name="form1" method="post" action="busca_op.php">
  2.          <table width="300" border="0" align="center" cellpadding="0" cellspacing="0" class="oSuperior">
  3.            <!--DWLayoutTable-->
  4.            <tr>
  5.              <td width="144" height="86" valign="baseline"><p class="estilo1"> Trabajador<span class="txt">
  6.                <select name="Numero" id="Numero">
  7.                  <?php
  8.                 conectar();
  9.                 $mydb=name;
  10.                 $consulta="select Apellido, Id_Empleado from tblempleados where activo='1' order by Nombre";
  11.                 $resultado=mysql_db_query($mydb,$consulta) or die("error al consultar nombres de equipos: ".mysql_error());
  12.                 if (mysql_num_rows($resultado)!=0){
  13.                     while ($campo = mysql_fetch_array($resultado)){
  14.                                                        
  15.                         echo "<option value=\"".$campo['Id_Empleado']."\">".$campo['Apellido']."</option>";
  16.                     }
  17.                    
  18.                 }
  19.    
  20.                 ?>
  21.                </select>
  22.              </span></p>             </td>
  23.              <td width="4">&nbsp;</td>
  24.              <td width="65" valign="baseline">Calendario
  25.              <input name="desde" type="text" id="desde" onclick="popUpCalendar(this, form1.desde, 'dd-mm-yyyy');" size="10" /></td>
  26.              <td width="4">&nbsp;</td>
  27.              <td width="65" valign="baseline">Calendario
  28.              <input name="hasta" type="text" id="hasta" onclick="popUpCalendar(this, form1.hasta, 'dd-mm-yyyy');" size="10" /></td>
  29.              <td width="78" valign="baseline"><p>&nbsp;
  30.              </p>               <p align="center">
  31.                <input name="Enviar" type="submit" class="optionitem" value="Ir" />
  32.                </p></td>
  33.            </tr>
  34.          </table>
  35.          </form>

Buscar:
Código php:
Ver original
  1. <?php
  2. function cambiaf_a_mysql ($fecha){
  3.     if($fecha!='')
  4.     {
  5.         ereg( "([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $fecha, $mifecha);
  6.         $lafecha=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1];
  7.         return $lafecha;
  8.     }
  9.     else
  10.     {
  11.         return false;
  12.     }    
  13. }
  14. $desde=$_POST['desde'];
  15. $hasta=$_POST['hasta'];
  16. $Numero=$_POST['Numero'];
  17. $fechas="";
  18. $id_opPOST="";
  19.  
  20. if(cambiaf_a_mysql($desde)!=false && cambiaf_a_mysql($hasta)!=false)
  21. {
  22.   $fechas="'".cambiaf_a_mysql($desde)."' <= p3.Fecha and p3.Fecha <= '".cambiaf_a_mysql($hasta)."' and ";
  23. }
  24. if($Numero!='')
  25. {
  26.    $id_opPOST="p3.id_op=".$Numero." and ";
  27. }
  28. $desde=cambiaf_a_mysql($desde);
  29. $hasta=cambiaf_a_mysql($hasta);
  30.  
  31. //consultas sql
  32. $consulta ="select p1.Nombre as id_Cliente, p2.Nombre,p3.Fecha as Fecha,p4.Nombre as producto
  33. from tblclientes as p1, tblempleados as p2, tbl_op as p3,tblproducto as p4,tblproducciones as p5
  34. where ".$fechas." ".$IDGuiaPOST."
  35. p3.id_Cliente=p1.id_Cliente
  36. and p4.id_Producto=p5.id_Producto
  37. and p3.id_op=p5.id_op order by p3.Fecha";
  38.  
  39. echo "<script>alert(\"$consulta\")</script>";
  40. $_SESSION['consultEXCEL']=$consulta;
  41. $resCons=mysql_query($consulta);
  42.  
  43.  
  44. echo"<h2>Informe Produccion :</h2>";
  45. //$total=0;
  46. while($row=mysql_fetch_array($resCons))
  47.  
  48.  
  49. {
  50.     echo"<div class='datos'>
  51.     <b>Cliente</b>: ".$row['id_Cliente']."<br>
  52.     <b>Nombre Trabajador </b>: ".$row['Nombre']."<br>
  53.     <b>Fecha</b>: ".$row['Fecha']."<br>
  54.  
  55.      </div><br>";
  56. }
  57. ?>

Copia estos dos, dime que te imprime.

Saludos
__________________
..::The Saint::..
El pesimista se queja del viento; el optimista espera que cambie; el realista ajusta las velas.