Deleting an Item from a Shopper's Basket


Introduction.  This page will be a fairly simple processing script that deletes an item based on which button is pushed.
  • the item to be deleted is identified by id_basket_item
    • which is passed in the URL

The following PHP page should be called delete_item.php and it should be uploaded to your firefox website.


<!-- delete_item.php - deleting an item from a shopper's basket -->

// obtaining the id for the basket item the shopper wants to delete
$id_basket_item = $_REQUEST["id_item"];
// connecting to the database on
$link = mysql_connect($host, $user, $password);
// now we need to get all the basic info on the item
// in order to delete it from the basket_item table

$query_string = "DELETE FROM basket_item WHERE id_basket_item = $id_basket_item";
mysql_db_query($db_name, $query_string, $link);



We now give some discussion of the code.

  • we start by obtaining the $id_basket_item using the $_REQUEST for what we passed as id_item from the basket.php
  • we make our connection to the database
  • we develop the query_string for the deletion
  • we execute the query_string
  • we close the link
  • we redirect the shopper back to their basket