<table width= "100%" border= "1" cellpadding= "0" cellspacing= "0" >
<tr>
<td> Code </td>
<td> name </td>
<td> Sex </td>
<td> ethnic </td>
<td> Birthdays </td>
</tr>
<?php
1. Create a Mysqli object, create a Connection object
$db = new mysqli ("localhost", "username", "password", "database Name");
2. Prepare an SQL statement
$sql = "SELECT * from Info";
3. Execute the SQL statement and, if it is a query statement, successfully return the result set object
$reslut = $db->query ($sql);
4. Determine if the return execution was successful
if ($reslut)
{
while ($attr = $reslut->fetch_row ())
{
echo "<tr>
<td>{$attr [0]}</td>
<td>{$attr [1]}</td>
<td>{$attr [2]}</td>
<td>{$attr [3]}</td>
<td>{$attr [4]}</td>
</tr> ";
}
}
?>
</table>
Fetch_all () returns all arrays
Fetch_row () returns an indexed array
FETCH_ASSOC () returns an associative array
Fetch_object () returns the object
Fetch_array () returns an array of both indexed and associated
Database Delete, add, modify operation
<?php
Connecting objects
$db = new mysqli ("localhost", "username", "password", "database Name");
Preparing SQL statements
$sql = "Delete from info where code= ' p004 '"; Delete
$sql = "Insert Course values" increment
$sql = "Update table name set field = information where field = info" Change
Execute SQL statement
$r = $db->query ($sql);
if ($r)
{
echo "Successful execution";
}
Else
{
echo "Failed to execute";
}
?>
PHP MySQL operation