Ver Mensaje Individual
  #13 (permalink)  
Antiguo 07/12/2009, 11:11
Maru77
 
Fecha de Ingreso: agosto-2003
Mensajes: 524
Antigüedad: 20 años, 8 meses
Puntos: 5
Respuesta: Ayuda con pase de variables

Si lo hago con el if (como lo dejé anteriormente) los datos pasan a la pagina2, respondiendo a tu otra pregunta, la cantidad es un dato variable.

Otra forma para armarlo que se me ocurre es con una estructura switch case, pero no se como armar el formulario para eso, copio lo que tengo a continuación

En el formulario no se como poner para que al hacer click vaya a la opción add_item del case

Código PHP:
<form action="cart.php" method="post">
            
            <?php
            
while($row mysql_fetch_array($_pagi_result))
            {
            
?>
                <tr>
                    <td width="10%" height="25">
                        <font face="verdana" size="1" color="black">
                            <?php echo $row["codigo_producto"]; ?>                        </font>                    </td>
                    <td width="25%" height="25">
                        <font face="verdana" size="1" color="black">
                            <?php echo $row["detalle_producto"]; ?>                        </font>                    </td>
                         
                    <td width="20%" height="25">
                        <font face="verdana" size="1" color="black">
                            $<?php echo $row["precio_producto"]; ?>                        </font>                    </td>
                    <td width="10%" height="25">                                           
                        <input name="cantprod_pedido" type="text" size="5">                    
                     </td>
                  <td width="10%" height="25"><label>
                      <input type="submit" name="action" id="agregar" value="Agregar">
                    </label></td>

              <td width="10%" height="25">
                    </td>                
                </tr>
                <input type="hidden" name="id_prod" value="<?php echo $row["id_producto"]; ?>" size="5">  
        </form>        
                
            <?php
            
}        
        
?>        
            
        </table>

Estructura de switch case que armé

Código PHP:
switch($_POST["action"])
        {        
           case 
"add_item":
           {
                   
AddItem($_POST["id_prod"]);
                
Mostrar();    
                break;
           }
           case 
"remove_item":
           {
                
RemoveItem ($_POST["id_prod"]);
                
Mostrar();
                break;
            }
            default:
            {
                
Mostrar();
            }        
        } 

Gracias Mortiprogramador!
__________________
Saludos!!!
Maru.-