Head First PHP&MYSQL study notes (ii)

Source: Internet
Author: User
Three. Create and populate the database

1. A Web application is a dynamic Web site designed to meet a user's specific goals

2. In PHP code, the SQL statement does not need to end with a semicolon, and each SQL statement at the end of the MySQL terminal has a semicolon

3. Creating databases: CREATE DATABASE database_name

Creating tables: CREATE TABLE table_name (column_name1 column_type1,column_name2 column_type2,......)

Select default database: Use database_name

Structure of the display table: DESCRIBE table_name

Delete tables: DROP TABLE table_name

Delete data: Delete from table_name

Specify a range with a WHERE clause

4. There may be objections to how the yes/no value is represented in MySQL, char (1) This method is straightforward and efficient.

5. Prompt, which indicates that you are still entering the same statement, the statement ends with a semicolon and MySQL executes the statement

6. The Mysqli_fetch_array () function stores a row of data in an array

7. Code examples

 
   
   
  $from = ' jarray@foxmail.com ';  $subject = $_post[' subject ');  $text = $_post[' Elvismail ');  $DBC = Mysqli_connect (' localhost ', ' root ', ' ', ' elvis_store ') or Die (' Error connecting to MySQL server. ');  $query = "SELECT * from Email_list";  $result = Mysqli_query ($dbc, $query)            //Execute SQL Statement or Die (' Error querying database. ');    while ($row = Mysqli_fetch_array ($result))     the {//While loop condition is the return value of the Mysqli_fetch_array () function $to = $row [' email '];    $first _name = $row [' first_name '];    $last _name = $row [' last_name '];    $msg = "Dear $first _name $last _name,\n$text";    Mail ($to, $subject, $msg, ' from: '. $from); Echo ' Email sent to: '. $to. '
'; } mysqli_close ($DBC);? >

 
     

The above describes the head first PHP&MYSQL study Note (ii), including the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.