Thanks but someone already helps me!!
But at this moment I wan't a field to insert a amount of a product and I wan't to show the total price of the product. I don´t know sure what to do!!! It´s similar to the checkboxes?? How can correspond to a selected checkbox??
Thanks for all!!!
Hello!! Can you help me with this??
Code
<input name="produto[]" type="checkbox" value="<? echo $arrl["nome"]; ?>">
...
<input name="quant[]" type="text" size="1">
$produto = $_POST["produto"];
$quant = $_POST["quant"];
PHP Code:
<?
if($produto)
{
foreach ($produto as $p)
{
$sql = "select * from produtos p, tipo_prod t where p.tipo_ID = t.tipo_ID and p.nome = '".$p."'";
$queryl = query($sql) or die ("Query failed: " . mysql_error() . " Actual query: " . $sql);
$arrl = mysql_fetch_array($queryl);
$conta = $arrl["preco"];
foreach ($quant as $q)
{
$total_prod = $conta * $q;
echo $arrl["tipo_nome"]." - ".$p." - ".$total_prod."<br />";
}
//echo $conta."<br />";
$total[] = $conta;
}
//echo "Total: ".array_sum($total);
}
else
{
echo "<script>alert('Para realizar uma encomenda necessita de escolher pelo menos um produto');</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=mag_order_1.php\">";
}
?>
An Output:
T-Shirt´s - Very Hot - 4
T-Shirt´s - Very Hot - 0
T-Shirt´s - Very Hot - 0
1 product selected with amount of 1. There are 3 products registered.
Bookmarks