I have a issue. the following code loops a list of products with checkboxes beside them. once the list of products finishing looping through, 2 submit buttons pop up. one for deleting and one for inserting those products into another database. right now both of these buttons are unique. if you click both of them they all perform the same operation
<?php $numrows = mysql_num_rows($results); ?>
<form action="admin.php?admin=3&update=1" method="post">
<?php while ( $row = mysql_fetch_assoc($results)){ ?>
<tr>
<td>
<input
type="checkbox"
name="product[]"
value="<?php echo $row['ProductID'];?>" />
</td>
<td align="left">
<a href="admin.php?admin=4&productID=<?php echo $row['ProductID'];?>">
<?php echo $row['productName']." ".$row['ProductID'];?></a> </td>
<td>
<?php printf('$%.2f',$row['productPrice']);?> </td>
</tr>
<?php $numrows = --$numrows ?>
<?php if ($numrows == 0) { ?>
<tr>
<td>
<input type="submit" name="submit" value="Add to Store Front" />
</td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Delete" /></td>
</tr>
</form>
<?php } ?>
<?php }?>
</table>
if you click either button, they all perform the same operation. the operation below is what is performed on the next page
foreach ( $_POST as $key => $var)
{
foreach ( $var as $key1 => $var1)
{
echo $key."[".$key1."]"." = ".$var1."</br>";
}
}
exit();
Once I open it up in a browser window, and lets say I checked 6 boxes. then i will get this output.
product[0] = 23 <----these are correct values
product[1] = 24
product[2] = 25
product[3] = 26
product[4] = 27
product[5] = 28
Everything works proper. perfect.
i get all the values and everything. everything works properly except i get this error and i dont know why. everything works but i get this error
Warning: Invalid argument supplied for foreach() in C:\www\apache\htdocs\admin.php on line 185