Data access, data access layer

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.