<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >PHP//1. Making Connection Objects$db=NewMysqli ("localhost", "User name", "Password", "Database to operate");//2. Determine if the link is wrongif(Mysqli_connect_error()){ die("Connection Failed");}//3. Preparing SQL statements$sql= "SELECT name from info where code= ' p001 '";//4. Execute SQL statement, return result set object$result=$db->query ($sql);//5. Take data from the result set//$attr = $result->fetch_all ();//Returns a two-dimensional array with all parameters//three optional parameters: Mysqli_assoc Returns an associative array, Mysqli_num returns an indexed array , Mysqli_both returns both index and association, and does not need double quotation mark//fetch_attry (); Returns the current data, returns a one-dimensional array, the default is the index association has//FETCH_ASSOC (); Returns the current data, Returns an associative array of one dimension//fetch_object (); Returns the object of the current data//fetch_row (); Returns the current data, returning an indexed array/*$attr = $result->fetch_all (), foreach ($attr as $v) {echo "<div>{$v [0]}--{$v [1]}</div>";}*//*While ($attr = $result->fetch_row ()) {echo "<div>{$attr [0]}--{$attr [1]}--{$attr [2]}--{$attr [3]}--{$ Attr[4]}</div> "; }*/$attr=$result-Fetch_all ();//Var_dump ($attr);//echo $attr [0][0]?></body>Connect Database query Basics