I want to DELETE a selected item while

-1

I have a cart system on my website, I have no problem to insert the products in it, to add their prices, the problem arises when I want to delete the products. I do not want to empty the entire cart, I want each product to have its button to delete and only the selected product is deleted. I bring my products with a while, since I have the cart items in a database, and each product that the user enters already generates its button to delete. The problem is that no matter which button to delete click, I emptied the cart. It must be a problem in the sentence, since the elimination is doing it without problems. Anyway, I clarify, I tested exactly the same sentence that I am using in my PHP directly in my database and I deleted exactly the book that I asked, but through php it is not working for me. I leave you code and I hope you can help me, thank you very much!

    
asked by Juan enriquez 29.11.2018 в 14:03
source

1 answer

1

The delete button does not refer to the id of the element, it should be something like:

<button type="submit" name="eliminar" value="<?=$row['idOrdenes']?>"></button>

So each button sends the id of the element and you capture it with:

  if ($_POST['eliminar']) {
      $id_eliminar = intval($_POST['eliminar']);
      .....
  }

for example.

    
answered by 29.11.2018 / 14:38
source