Bueno, consegui adaptar un script de un carro de la compra para mi web, pero me ha surgido un problema.
El codigo funciona bien con 1 tipo de producto, pero yo tengo 2 distintos. que son aires y teles.
Pongo el codigo:
Boton para agregar item al carro:
Código PHP:
  
<a href="agregar.php?<?php echo SID ?>&id_aire=<?php echo $row['id_aire']; ?>"> 
<img src="images/boton_carro.png" border="0" title="Agregar al Carrito"></a>   Código PHP:
   if(!isset($cantidad)){$cantidad=1;} 
$qry=mysql_query("select * from aires where  
id_aire='".$id_aire."'"); 
$row=mysql_fetch_array($qry); 
if(isset($_SESSION['carro'])) 
$carro=$_SESSION['carro']; 
$carro[md5($id_aire)]=array('identificador'=>md5($id_aire), 
'cantidad'=>$cantidad,'nombre_aire'=>$row['nombre_aire'], 
'precio'=>$row['precio'],'id_aire'=>$id_aire); 
$_SESSION['carro']=$carro; 
if ($cantidad>1)
{
 
header("Location:".SID."".$_SERVER['HTTP_REFERER']);
 }
else
{
    header("Location:".SID."".$_SERVER['HTTP_REFERER']);
   }
    
?> 
   Código PHP:
   <?php  
if(isset($_SESSION['carro'])) 
$carro=$_SESSION['carro'];else $carro=false; 
if($carro){ 
 
?> 
<table width="590" border="0" cellspacing="0" cellpadding="0" align="center"> 
<tr bgcolor="#333333" class="tit">  
<td>Producto</td> 
<td>Precio</td> 
<td colspan="2" align="center">Cantidad de Unidades</td> 
<td align="center">Borrar</td> 
<td align="center">Actualizar</td> 
</tr> 
<?php 
$color=array("#ffffff","#F0F0F0"); 
$contador=0; 
$suma=0; 
foreach($carro as $k => $v){ 
$subto=$v['cantidad']*$v['precio']; 
$suma=$suma+$subto; 
$contador++; 
extract($v);
?> 
<form name="a<?php echo $v['identificador'] ?>" method="post" action="agregar.php?<?php echo SID ?>" id="a<?php echo $v['identificador'] ?>"> 
<tr bgcolor="<?php echo $color[$contador%2]; ?>" class='prod'>  
<td><?php echo $v['nombre_aire'] ?></td> 
<td><?php echo $v['precio'] ?> €</td> 
<td  align="center"></td> 
<td width="136" align="center">  
<input name="cantidad" type="text" id="cantidad" value="<?php echo $v['cantidad'] ?>" size="8"> 
<input name="id_aire" type="hidden" id="id_aire" value="<?php echo $v['id_aire'] ?>"> </td> 
<td align="center"><a href="borracar.php?<?php echo SID ?>&id_aire=<?php echo $v['id_aire'] ?>"><img src="images/trash.gif" width="12" height="14" border="0"></a></td> 
<td align="center">  
<input name="imageField" type="image" src="images/actualizar.gif" width="20" height="20" border="0"></td> 
</tr></form> 
<?php 
} 
?> 
</table>   Código PHP:
  
<td><?php echo $v['nombre_aire'] ?></td>   Código PHP:
  
<input name="id_aire" type="hidden" id="id_aire" value="<?php echo $v['id_aire'] ?>"> </td> 
<td align="center"><a href="borracar.php?<?php echo SID ?>&id_aire=<?php echo $v['id_aire'] ?>">   No se si me he explicado bien, si no se entiende me lo decis.
 

