[PHP] HeadFirst-PHP & MySQL (Chapter 2 summary)

Source: Internet
Author: User
[PHP] HeadFirst-PHP & MySQL (Chapter 2 summarizes) manual operations on a large amount of data is a very tedious task, so you need a database to help you manage data.

As a mainstream database, MySQL uses the SQL language. Generally, you can use the MySQL terminal and phpMyAdmin graphical tool to manage input. phpMyAdmin can be found on the local page of wnmp.

Generally, the user name for the first Test is root, and the password for the first Test database is password. MySQL command

Create database example; CREATE a DATABASE example

USE example; select to USE example database

Create table users (

Name varchar (30 ),

Email varchar (50 ),

)

The users table created in the example database contains two columns: name and email. the varchar types are 30 and 50, respectively.

Insert into users (name, email)

VALUES ('Jack', 'jacksemail @ gmail.com ')

Insert data to the users Table. the name corresponds to 'Jack', and the email corresponds to 'jacksemail @ gmail.com'

SELECT * FROM users

Request data from all columns in the users table

SELECT name FROM users

Request data in the name column of the users table

SELECT name, email FROM users

Request data in the name and email columns of the users table

MySQL commands in PHP

Mysqli_connection ('database location ', 'database username', 'database password', 'database name ')

Database location = domain name, IP address or localhost

Database username = root (MySQL default)

Database password = password (MySQL default)

Database name = example (custom database name)

Mysqli query (databaseconnect, query );

Use a database connection and a query string to complete SQL queries

My close (databaseconnect)

Close connection

  

Summary

This chapter describes how to create a database table, insert data, and query data in the database, and connect to the database, insert data, and close the database in php.

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.