Código PHP:
foreach ($_POST as $idarticle => $quantitat)
{
if (!empty($quantitat))
{
$carrito[]=array($idarticle,$quantitat);
}
}
$_SESSION['carrito']=$carrito;
Código PHP:
<table width="75%"align="center" cellspacing=0 cellpadding=0 bgcolor="#CCCCCC" border=0>
<tr>
<td height="10px" width="10px"></td>
<td height="10px" align="left">
<p align="left"><a href="index.php?fuseaction=list"><img src="../../../../img/sortir.gif" width="91" height="25" border="0"></a></p>
</td>
<td height="10px" align="right">
<p align="right"><a href="javascript:envia();"><img src="../../../../img/continuar.gif" width="91" height="25" border="0"></a></p>
</td>
<td height="10px" width="10px"></td>
</tr>
<tr>
<td height="10px" width="10px"></td>
<td align="center" colspan="2"><font size="3"><strong>Comandes</strong></font><p></p>
<table width="75%" cellpadding="0" cellspacing="0" class="list">
<tr>
<td align="left" class="listheader">Codi</td>
<td align="center" class="listheader">Article</td>
<td align="center" class="listheader">Quantitat</td>
</tr>
<?
foreach ($_POST as $idarticle => $quantitat)
{
if (!empty($quantitat))
{
$carrito[]=array($idarticle,$quantitat);
}
}
$_SESSION['carrito']=$carrito;
//echo "<pre>";
//print_r($_SESSION['carrito']);
//echo "</pre>";
$numarray= count($carrito);
for ($i=0;$i=$numarray;$i++){
echo "<tr>";
echo "<td align='left' class=listitem>".$carrito[$i]."</td>";
echo "</tr>";
}
</table>
?>