How to delete multiple item on php session?

APPERAZER

New Member
Hi I have a shopping cart but my problem is when I delete multiple Item it wont process but if I delete only one item on check box it work well here is my code below I want to figure out if what is wrong on my code:\[code\] $cart = $_SESSION['items'];if(isset($_POST['del'])) { if ($cart) { $newcart = array(); foreach ($cart as $item) { foreach ($_POST['itemid'] as $del) { $delete = $del; } if ($del != $item) { if ($newcart != '') { $newcart[] = $item; } else { $newcart[] = $item; } } } $cart = $newcart; }}$_SESSION['items'] = $cart;\[/code\]Here is my form:\[code\]<form action="cart.php" method="post"><table><tr><td><input type="checkbox" name="itemid[]" value="http://stackoverflow.com/questions/10545289/1"></td><td>Item 1</td><td>5</td></tr><tr><td><input type="checkbox" name="itemid[]" value="http://stackoverflow.com/questions/10545289/2"></td><td>Item 2</td><td>5</td></tr><tr><td><input type="checkbox" name="itemid[]" value="http://stackoverflow.com/questions/10545289/3"></td><td>Item 3</td><td>5</td></tr><tr><td><input type="checkbox" name="itemid[]" value="http://stackoverflow.com/questions/10545289/4"></td><td>Item 4</td><td>5</td></tr><tr><td colspan="2"><input type="submit" name="del" value="http://stackoverflow.com/questions/10545289/Delete"></td></tr></table></form>\[/code\]If I check multiple Item and submit the delete button, the item was not delete but if I only check one the item deleted.Thank you for you help very much appreciated.
 
Back
Top