| PHP Data access:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<body>
<?php
Build a connection, create a Connection object
$db = new Mysqli ("localhost", "root", "123", "MyDB");
Judging if there is an error
/*if (Mysqli_connect_error ())
{
echo "Connection failed! ";
Exit
}*/
Mysqli_connect_error () Die ("Connection Failed"): "";
Write SQL statements
$sql = "SELECT * from Info";
Executes the SQL statement, returning the result set object
$reslut = $db->query ($sql);
Reading data from the result set, returning an array
$attr = $reslut->fetch_all (); Reads all data, returns an indexed two-dimensional array
$attr = $reslut->fetch_array (); Reads the data that the current pointer points to, and returns an array that exists for the Index association
$attr = $reslut->fetch_assoc (); Returns an associative array
$attr = $reslut->fetch_row (); Returns an indexed array
$attr = $reslut->fetch_object (); Return object
/* $arr = array ();
while ($attr = $reslut->fetch_row ())
{
Array_push ($arr, $attr);
}
Var_dump ($arr); * *
?>
</body>
|