Piotto
11-15-2009, 09:22 AM
Hi Dynamic people!
I am using this code to get data from a form with textboxes and checkboxes.
All checkboxes in the sending form have the same name witch is "pickitem[]".
[CODE]
<?php
if(isset($_POST['calcular']))
{
$verify = $_POST['pickitem'];
$itemname = $_POST['itemname'];
$itemprice = $_POST['itemprice'];
$itemquantity = $_POST['itemquantity'];
$subtotal = $itemprice * $itemquantity;
if(empty($verify))
{
echo("<p><center><b>Must select something!</center></b></p>\n");
}
else
{
$N = count($verify);
echo "You have selected $N Products<br><br>";
for($i=0; $i < $N; $i++)
{
echo $itemname . " - " . $itemprice . " - " . $itemquantity . " - " . $subtotal . "<br>";
}
}
}
?>
[CODE]
Problem is that the echo result is wrong, because i have the same item data (name, price, quantity and subtotal of course) repeated $N times.... on $N rows.
Why? What I have missed?
Alex Piotto :confused:
I am using this code to get data from a form with textboxes and checkboxes.
All checkboxes in the sending form have the same name witch is "pickitem[]".
[CODE]
<?php
if(isset($_POST['calcular']))
{
$verify = $_POST['pickitem'];
$itemname = $_POST['itemname'];
$itemprice = $_POST['itemprice'];
$itemquantity = $_POST['itemquantity'];
$subtotal = $itemprice * $itemquantity;
if(empty($verify))
{
echo("<p><center><b>Must select something!</center></b></p>\n");
}
else
{
$N = count($verify);
echo "You have selected $N Products<br><br>";
for($i=0; $i < $N; $i++)
{
echo $itemname . " - " . $itemprice . " - " . $itemquantity . " - " . $subtotal . "<br>";
}
}
}
?>
[CODE]
Problem is that the echo result is wrong, because i have the same item data (name, price, quantity and subtotal of course) repeated $N times.... on $N rows.
Why? What I have missed?
Alex Piotto :confused: