Sending Requests to the Database

After connecting to the database, you can send queries to it. This is done using the mysqli_query function. The first parameter of this function takes the variable in which we stored the result of mysqli_connect, and the second - a string with the SQL query.

For example, let's execute a query that will fetch all records from the users table:

php<?php
  $res = mysqli_query($link, 'SELECT * FROM users');
?>

The query text does not have to be written directly in the function parameter mysqli_query. Let's put it into a variable:

php<?php
  $query = 'SELECT * FROM users';
  $res = mysqli_query($link, $query);
?>