After the MySQL connection is successful, you can use Msql_query to obtain a resource-based result set.
$sql = ' select * from Emp_info ';
$result = mysqli_query ($link, $sql);
You can then use functions such as MYSQL_FETCH_ASSOC (), Mysql_fetch_row (), mysql_fetch_array (), mysql_fetch_object () to work with the result set.
The purpose of the MYSQL_FETCH_ASSOC () function is to obtain a row of data from the result set and return it as an associative array whose "key" is the field name of the data table, and "value" is the data for that field. When MYSQL_FETCH_ASSOC () executes successfully, it is automatically moved to the next row of the result set to continue reading until all the data has been read.
$emp _info = Array ();
while ($row = Mysqli_fetch_assoc ($result)) {
$emp _info[] = $row;
}
The function of the mysql_fetch_row () function is to read a row of data from the result set and return it as an indexed array. The method of declaration is the same as Assoc.
The array function returns the result in the form of an indexed array and an associative array, respectively.
object is similar to an array, except that it returns an object instead of an array, and only accesses the data through the word by.
PHP Database result set processing