Viewing Data from the Database in PHP

Let's create a page show.php, where we can view the user's data formatted with a specific layout.

Let's assume we are given the following layout for this:

html<div>
  <h1>user1</h1>
  <p>
    age: <span class="age">23</span>,
    salary: <span class="salary">400</span>
  </p>
</div>

Let the id of the user we want to view be passed via the GET parameter named id. Let's get it into a variable:

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

Let's form a query to get this user:

php<?php
  $query = "SELECT * FROM users WHERE id=$id";
?>

Let's execute the query:

php<?php
  $result = mysqli_query($link, $query) or die(mysqli_error($link));
?>

Let's write the user data into a variable:

php<?php
  $user = mysqli_fetch_assoc($result);
?>

Let's output this data in our layout:

html<div>
  <h1><?= $user['name'] ?></h1>
  <p>
    age: <span class="age"><?= $user['age'] ?></span>,
    salary: <span class="salary"><?= $user['salary'] ?></span>
  </p>
</div>
Задание 1

Implement the user view using the following layout:

html<div>
  <p>
    name: <span class="name">user1</span>
  </p>
  <p>
    age: <span class="age">23</span>,
    salary: <span class="salary">400$</span>,
  </p>
</div>
Задание 2

On the page index.php, implement the output of links to view each of the users:

html<a href="/en/show.php?id=1">user1</a>
<a href="/en/show.php?id=2">user2</a>
<a href="/en/show.php?id=3">user3</a>