PHP 7 connection MySQL database, nonsense not much said, directly on the code:
Host Name
$db _host = ' localhost ';
User name
$db _user = ' root ';
Password
$db _password = ' root ';
Database name
$db _name = ' 87a87a_com ';
Port
$db _port = ' 3306 ';
Connecting to a database
$conn = Mysqli_connect ($db _host, $db _user, $db _password, $db _name) or Die (' failed to connect to the database! ');
Select Database
mysqli_select_db ($conn, $db _name) or Die (' Select database failed! ');
Querying the database
$result = Mysqli_query ($conn, "SELECT * from Caiji_htmlid");
Processing the returned dataset
$data = [];
while ($row = Mysqli_fetch_assoc ($result)) {//mysqli_fetch_array
$data [] = $row;
}
Print on the page
Var_dump ($data);
You can either pass in the $db_nname when the Mysqli_connect call, or you can call mysqli_select_db to select the database separately. In addition, the difference between MYSQLI_FETCH_ASSOC and Mysqli_fetch_array, we printed the results will be known.