I have tried to create an array in a form to process on the next page but am getting problems with it.
I have two entires the user has to do which is "select the items" and set the "quantity" of those items..
So lets say:
ItemID |Quantity
---3------|------4
---2------|------2
---7------|------1
These are the items the user picked and the corresponding quantities. Now i have applied that to my form below:
Code: Select all
<?php
$Array = 0;
While($row = mysql_fetch_assoc($GetItems)){
$ItemID = $row['ItemID'];
$Quantity = $row['Quantity'];
$Get = mysql_query("SELECT Name,Type FROM item WHERE ItemID='$ItemID' AND Trade='1'")
Or die(mysql_error());
$row = mysql_fetch_assoc($Get);
$Name = $row['Name'];
$Type = $row['Type'];
$Array++;
?>
<tr>
<td width="200" align="center" class="blackBold"><?=$Name?></td>
<td width="200" align="center" class="blackBold"><?=$Quantity?></td>
<td width="200" align="center" class="blackBold"><input type="text" size="16" name="Quantity[<?=$Array?>]" value=""></td>
<td width="200" align="center" class="blackBold"><input type="checkbox" name="Checkbox[<?=$Array?>]" value="<?=$ItemID?>"></td>
</tr>
<?php
}
?>This is my process:Notice: Undefined variable: ItemID in C:\xampp\htdocs\transferprocess.php on line 5
Code: Select all
<?php
If(isset($_POST['Button1']) && isset($_POST['Checkbox']) && isset($_POST['Quantity'])){
for($Array = 0; $Array < count($ItemID); $Array++){
if($Quantity[$Array]){
echo $ItemID[$Array] . " - " . $Quantity[$Array];
}else{
echo "Please insert a quantity for item id " . $item[$a];
}
}
}
?>It's so confusing! Not sure if I am going in the right direction? Hope you can help me here I ain't totally understood array's greatly.