Deleting Data from the Database Using GET Requests

Let's now delete records from the database by passing the id for deletion via GET parameters.

Suppose we have a GET parameter named del. Let's get the id for deletion into a variable:

html<?php
  $del = $_GET['del'];
?>

Let's form a deletion query:

html<?php
  $query = "DELETE FROM users WHERE id=$del";
?>

Delete the record from the database:

html<?php
  mysqli_query($link, $query) or die(mysqli_error($link));
?>
Задание 1

Make it so that in the address bar it is possible to send a GET request with the user's id and this user gets deleted from the database.

Задание 2

Modify the previous task so that the page has links to delete each user:

html<a href="?del=1">user1</a>
<a href="?del=2">user2</a>
<a href="?del=3">user3</a>

The links, of course, should be generated in a loop from the data received from the database.

Задание 3

Modify the previous task so that you have the following HTML code:

html<ul>
  <li>user1 <a href="?del=1">delete</a></li>
  <li>user2 <a href="?del=2">delete</a></li>
  <li>user3 <a href="?del=3">delete</a></li>
</ul>
Задание 4

Modify the previous task so that you have the following HTML code:

html<table>
  <tr>
    <th>id</th>
    <th>name</th>
    <th>age</th>
    <th>salary</th>
    <th>delete</th>
  </tr>
  <tr>
    <td>1</td>
    <td>user1</td>
    <td>23</td>
    <td>400</td>
    <td><a href="?del=1">delete</a></td>
  </tr>
  <tr>
    <td>2</td>
    <td>user2</td>
    <td>25</td>
    <td>500</td>
    <td><a href="?del=2">delete</a></td>
  </tr>
  <tr>
    <td>3</td>
    <td>user3</td>
    <td>23</td>
    <td>500</td>
    <td><a href="?del=3">delete</a></td>
  </tr>
</table>