Foros del Web » Programando para Internet » PHP »

Pedidos PHP

Estas en el tema de Pedidos PHP en el foro de PHP en Foros del Web. La intension es buscar codigo en tabla una tabla de datos ya existente. A medida que 'Agrego al Pedido', ir armando la muestra (item-codigo-descripcion-cantidad). No ...
  #1 (permalink)  
Antiguo 06/11/2009, 14:39
 
Fecha de Ingreso: octubre-2005
Mensajes: 405
Antigüedad: 18 años, 6 meses
Puntos: 1
Pedidos PHP

La intension es buscar codigo en tabla una tabla de datos ya existente.
A medida que 'Agrego al Pedido', ir armando la muestra (item-codigo-descripcion-cantidad).
No funciona la iteracion de los productos, una vez encontrado en la base
el campo item se debe ir incrementado a medida de los item desplegados en la iteracion.
Mostrar titulo solo cuando item = 1
Espero haberme dado a entender.
Código PHP:
<?                                                                              
 $titulo
="Solicitud de Productos a Bodega";                                     
 
$elige=$_GET["elige"];                                                         
 
$item=$_REQUEST['item'];                                                       
?>                                                                              
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">                                      
 <html>                                                                         
 <head>                                                                         
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />    
  <title>Solicitudes a Bodega</title>                                           
<style type="text/css">                                                         
<!--                                                                            
#procesar { font-family: "Trebuchet MS"; font-size: 10px; font-weight: bold; text-transform: uppercase; color: #000066; background-color: #F1F1F1; border: 1px solid #666666; }
.Estilo1 {font-family: "Trebuchet MS"; font-size: 10px; font-weight: bold; color: #000066; text-transform: uppercase;}                                                                               
.Estilo2 {font-family: "Trebuchet MS"; font-size: 10px; }                                                                               
#linea {border-collapse:collapse; border-color:#00379B;}                        
-->                                                                             
</style>                                                                        
</head>                                                                        
<body>                                                                         
 <div align=center><span style="width:100%; font-size: 12px; font-family: Verdana; color: #00379B; font-weight: bold;"><? echo $titulo?></span></div>         
 <form action="solicitud.php" method="get">                                     
 <table width=97% border=1 cellspacing=0 cellpadding=2 align=center id=linea>   
  <tr class=datos>                                                              
    <td colspan=2 bgcolor=#00379B id=linea>B&uacute;squeda de Productos</td>    
  </tr>                                                                         
  <tr class=Estilo2>                                                            
    <td align=center valign=middle id=linea>                                    
     <input name="elige" type="text" id="elige" value=".:: Codigo de Producto ::
." size="50" maxlength="40" onfocus="if(this.value !=''){this.value=''; };return
 true;"/>&nbsp;<input type="submit" name="submit" id="procesar" value="Agregar a
 Pedido">                                                                       
    </td>                                                                       
  </tr>                                                                         
</table>                                                                        
</form><br>                                                                     
<?                                                                              
 
if(!isset($elige) == '')                                                       
 {                                                                              
   include(
"config.php");                                                       
   
$sql=mysql_query("select * from EXIPRO where CODPRO_P=$elige limit 0,1") or die("Problemas con conexion..<b>".mysql_error()."</b>");                         
   
$numeroRegistros=mysql_num_rows($sql);                                       
   if(
$numeroRegistros 0)                                                     
   {                                                                            
      
//Para generar item NO FUNCIONA.
      
if(!isset($item) == '') { $item=1; }                                      
      else { 
$item=$item+1; }                                                   
      if(
$item == 1)                                                            
      {                                                                         
      echo 
"<table width=97% border=1 cellspacing=0 cellpadding=2 align=center id=linea>                                                                        
             <tr class=Estilo1 bgcolor=#F1F1F1>                                 
              <td width=06% align=center id=linea>Item</td>                     
              <td width=15% align=center id=linea>C&oacute;digo</td>            
              <td width=55% align=center id=linea>Descripci&oacute;n</td>       
              <td width=10% align=center id=linea>Cantidad</td>                 
              <td width=14% align=center id=linea>Opciones</td>                 
             </tr>"
;                                                            
       }                                                                        
       
$fila=mysql_fetch_array($sql);                                           
       
$cod=$fila['CODPRO_P'];                                                  
       
$nom=$fila['NOMBRE_P'];                                                  
       
$cos=$fila['PRECOS_P'];                                                  
       
?>                                                                       
             <tr class=Estilo2>                                                 
              <td width=06% align=right id=linea><? echo $item?></td>         
              <td width=15% align=right id=linea><? echo $cod;  ?></td>         
              <td width=55% align=left  id=linea><? echo $nom;  ?></td>         
              <td width=10% align=right id=linea>&nbsp;</td>                    
              <td width=14% align=right id=linea>&nbsp;</td>                    
             </tr>                                                              
       <?                                                                       
   
}                                                                          
 }                                                                           
?>        
 </table> 
 </body>  
 </html>
Con este codigo siempre se me itera el titulo con el resultado de la consulta; es decir al parecer item siempre es = 1.

desde ya se agradece cualquier comentaria al respecto.
  #2 (permalink)  
Antiguo 06/11/2009, 16:54
Avatar de luckystrikede11  
Fecha de Ingreso: octubre-2009
Ubicación: Concepcion, Chile
Mensajes: 240
Antigüedad: 14 años, 6 meses
Puntos: 17
Respuesta: Pedidos PHP

No estas realizando ninguna iteracion...

algo asi te puede ayudar:
Código PHP:
while($fila=mysql_fetch_array($sql)){



  #3 (permalink)  
Antiguo 06/11/2009, 17:33
Avatar de TheoriaX  
Fecha de Ingreso: agosto-2009
Ubicación: Hermosillo, Sonora
Mensajes: 217
Antigüedad: 14 años, 8 meses
Puntos: 5
Respuesta: Pedidos PHP

es lo mas probable que con el while se haga la iteracion...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:27.