PHP MySQL Query
We have connected to the mysql server and then selected the database we want to use, now we can run an SQL query over the database to select information, do an insert, update or delete. To do this we use mysqli_query. This takes two arguments: the first is our link_identifier and the second is an SQL query string. If we are doing a select sql statement mysqli_query generates a resource or the Boolean false to say our query failed, and if we are doing a delete, insert or update it generates a Boolean, true or false, to say if that was successful or not. The basic code for running a query is the php function "mysqli_query($link, $query)". The "$query" argument is a MySQL query. The database argument is a database connection(here, the connection represented by $link). For example, to return the query "SELECT * FROM customers ORDER BY customer_id ASC", you could write
<?php
mysqli_query($link, "SELECT * FROM customers ORDER BY customer_id ASC");
?>
To catch an error, for debugging purposes, we can write:
<?php
$result = mysqli_query ($link, "SELECT * FROM customers ORDER BY customer_id ASC"); or die (mysqli_error () . " The query was:" . $sql_query);
?>
If the function mysqli_query returns false, PHP will terminate the script and print an error report from MySQL (such as "you have an error in your SQL syntax") and the query. 

