PHP Delete from DB

We will now use our users table inside the database examples:

users table

 

 

 

 

Our users table has 3 columns: id, name, surname.

To DELETE a row from a table we will:

  1. connect to the server (localhost)
  2. select a database (examples)
  3. create a SQL DELETE query
  4. run the query and store the result
  5. check if the query has been successful

PLEASE NOTE: the DELETE command is quite powerful, if you do not specify which row you want to delete, ALL the rows will be deleted. That’s why you should always use a WHERE clause.