Ver Mensaje Individual
  #24 (permalink)  
Antiguo 25/01/2012, 16:59
Crea
 
Fecha de Ingreso: abril-2008
Mensajes: 50
Antigüedad: 16 años
Puntos: 3
Respuesta: Como armar variable para tomar otro dato

Te paso todo el código para que veas como lo incluí:

Código PHP:
<?php
            
/*MOSTRAR Carro*/
            
$id $_GET['id'];
            
            
$resultado mysql_query("SELECT id, producto, precio FROM productos WHERE id='1'")or die( "Error en query: $sql, el error  es: " mysql_error() );
            
            
//Desplegamos una tabla con los datos de los productos
            
echo "<div class=verproductos>";
            echo 
"<table style=border:1px solid #333333>
                <tr class=titulo>
                    <th style='display:none'>ID</th>
                    <th class='desc_largo'>Producto</th>
                    <th style='width:100px;text-align:right'>Precio</th>
                    <th style='width:50px;text-align:right'>Acción</th>
                </tr>"
;
                
            
// comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen
            
while ($productos mysql_fetch_array($resultado)) { 
                echo 
"<tr class='borde_tabla'><td style='display:none'>" $productos['id'] . "</td>";     // imprime el texto
                
echo "<td>" $productos['producto'] . "</td>";     // imprime el nombre
                
?>
                <td>
                <?php
                
                
* * if(isset($_SESSION['carro'][$productos['id']])){ ?>
* * <form method="post" action="carro.php?id=<?php $productos['id']; ?>&action=removeProd">
* * <?php }else{?>
* * <form method="post" action="carro.php?id=<?php $productos['id']; ?>&action=add">
* * <?php }?>
* * *
* * *
* * <select name="color">
* * <option value="">seleccionar</option>
* * *
* * <?php
* * while($fila=mysql_fetch_row($result)){
* * echo 
"<option value='".$fila['1']."'>".$fila['1']."</option>";
* * }
* * 
?>
* * *
* * </select>
* * *
* * <?php
* * if(isset($_SESSION['carro'][$productos['id']])){ ?>
* * <input name="" type="image" src="img/remove_carro.png" width="50" height="50">
* * <?php }else{?>
* * <input name="" type="image" src="img/add_carro.png" width="50" height="50">
* * <?php }?>
* * *
* * </form></td>
                <?
                
                
echo "<td style='text-align:right'>" $productos['precio'] . " $ </td>"// imprime el precio
                
echo "<td style='text-align:right'>
                                <a href='carro2.php?id=" 
$productos['id'] . "&action=";
                                
//Detectamos si el producto ya se ha añadido al cesta de la compra para usar una imagen u otra.
                                //Si se ha añadido usamos una imagen para Restar una cantidad al carro
                                
if (isset($_SESSION['carro'][$productos['id']])){
                                    
//echo "remove' alt='Eliminar del carro'><img src='img/remove_carro.png' width='48' height='48' alt='Eliminar del carro' title='Añadir producto al carrito'>";
                                    
echo "removeProd' alt='Eliminar del carro'><img src='img/remove_carro.png' width='48' height='48' alt='Eliminar del carro' title='Añadir producto al carrito'>";
                                }
                                else
                                    echo 
"add' alt='Añadir al carro'><img src='img/add_carro.png' width='48' height='48' alt='Añadir al carrito' title='Añadir producto al carrito'>";
                                    
                                
                echo 
"</a></td>";
              echo 
"</tr>"
            } 
// fin del bucle de ordenes
                            
            //cerramos la etiqueta tabla
            
echo "</table>";
            
        
                
/*echo $_SESSION["totalcoste"] . "<br>";
                echo $_SESSION["cantidadTotal"] . "<br>";*/
            
            
echo "</div>";
        
?>