Data access, data access layer
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>
<Body>
<Table width = "100%" border = "1" cellpadding = "0" cellspacing = "0">
<Tr>
<Td> Code </td>
<Td> name </td>
<Td> gender </td>
<Td> ethnicity </td>
<Td> birthday </td>
</Tr>
<? Php
// Create a mysqli object and create a connection object
$ Db = new MySQLi ("localhost", "root", "123", "mydb ");
// Prepare an SQL statement
$ SQL = "select * from info ";
// Execute the SQL statement. If it is a query statement, the result set object is returned successfully.
$ Reslut = $ db-> query ($ SQL );
// Determine whether execution is 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>
</Body>
</Html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>
<Body>
<? Php
// Create a connection object
$ Db = new MySQLi ("localhost", "root", "123", "mydb ");
// Prepare SQL statements
$ SQL = "delete from info where code = 'p004 '";
// Execute the SQL statement
$ R = $ db-> query ($ SQL );
If ($ r)
{
Echo "execution successful ";
}
Else
{
Echo "failed to execute ";
}
?>
</Body>
</Html>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>
<Body>
<? Php
$ Db = new MySQLi ("localhost", "root", "123", "mydb ");
$ SQL = "select * from nation ";
$ Result = $ db-> query ($ SQL );
Echo "<select> ";
If ($ result)
{
While ($ attr = $ result-> fetch_row ())
{
Echo "<option value = '{$ attr [0]}' >{$ attr [1]} </option> ";
}
}
Echo "</select> ";
?>
</Body>
</Html>