Forum Moderators: coopster
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\show_order.php on line 21
My code looks like this:
(line 21 is the foreach line, it seems as if it does not like $_POST['qty'], but I could be wrong).
if(isset($_POST['submit5']))
{
foreach ($_POST['qty'] as $key => $value)
{
if ( ($value == 0) AND (is_numeric ($value)) )
{
unset ($_SESSION['cart'][$key]);
} elseif ( is_numeric ($value) AND ($value > 0) )
{
$_SESSION['cart'][$key] = $value;
}
}
later on in my code I have the following code to create an input element of text type:
echo " <tr>
<td align=\"left\"><a name=\"".$item."\" href=\"show_item.php?itemid={$row['item_id']}\">{$row['name']}</a><br> {$row['description']}</td>
<td align=\"left\"> <input type=\"text\" name=\"qty[{$row['item_id']}]\" value=\"{$_SESSION['cart'][$row['item_id']]}\"></td>
</tr>\n";
Thanks,
Lebman
Also take a look at where it is being set and try to figure out why it isn't working. It looks like the answer will be farther back in the chain of events and once you find it you can work your way forward again.