Chapter 7 - Data removal: Removing customer accounts from the database
Objective: A Web application for listing and deleting customers. Difficulty: *
Preparation
Duplicate file list_the_customers.php
from Chapter 3, rename it to D-CRUD.php
and put it at the root of your Web server.
For this last part of our tutorial, we will learn how to delete a resource.
Here is the complete, detailed code you need in order to remove a customer:
This code enables you to remove a customer whose ID is "3". As you can see, deleting the customer differs only slightly from retrieving a resource. In fact the only thing different in the code lies in the method called: We will no longer call this method get()
but instead simply delete()
!
You must now replace the customer ID by a dynamically-defined ID.
Now create all the script that will display a list of customer IDs and delete a customer of your choice.
Again, if you have trouble, look at the code from the 4-delete.php
sample file.
Last updated