Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shopping Cart Delete Button.

    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.

  • #2
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    *bump*

  • #3
    Regular Coder
    Join Date
    Sep 2005
    Location
    Liverpool
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    my mind is on a permanent tangent

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    PHP Code:
    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
    PHP Code:
    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());
            ....

    Last edited by raf; 09-11-2005 at 08:46 PM.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    New Coder
    Join Date
    Sep 2005
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot raf, I got it working. Appreciate the help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •