View Full Version : Shopping Cart Delete Button.

09-11-2005, 11:02 AM
Okay I am going to post a picture as to what I have.


Okay now what I want to know is how can I make it so that when someone checks the remove button next to a product and hits update it deletes? Someone please explain to me how I can go about doing this.

09-11-2005, 05:39 PM

Rich Pedley
09-11-2005, 08:30 PM
currently is the item still showing because it hasn't been deleted, or is still showing even though it has been deleted?

odds are you need to delete it from the whereever you are storing it *before* you redisplay the cart.

09-11-2005, 08:42 PM
i personaly prefer to see the code you use to generate the table, then a picture of it.
but anyway ... the idea is to create an array of the checkboxes inside your form. your code to generate these will look something like

echo '<td><input type="checkbox" name="removearticle[]" id="removearticle[]" value="', $row_articles['order_articleID'] ,'" /></td>';

where the order_articleID is the primary key of the article for that specific order. Lets say the PK of your table order_articles

When the form is posted, $_POST['removearticle'] will contain an array with the values (which are the PK's of table order_articles) of all checked boxes as members. this array then just needs to be turned into a commaseperated list.
so you can then remove these with something like

if (isset($_POST['removearticle']) and (count($_POST['removearticle'])>= 1)){
$delete = "DELETE FROM order_articles
WHERE order_articleID In (" . implode(', ' , $_POST['removearticle']) . ")";
mysql_query($delete, $link) or die('Queryproblem deleting articles:' . mysql_error());

09-12-2005, 05:44 PM
Thanks a lot raf, I got it working. Appreciate the help.