Chapter 2 PHP MySQL_PHP tutorial

Source: Internet
Author: User
Chapter 4 PHP operations on MySQL. Learning Tips: 1. connect PHP to MySQL2. add, delete, modify, and query. 3. if you have rich experience using PHP, SQL, and MySQL, you can now combine all these technologies. Learning points:
1. connect PHP to MySQL
2. add, delete, modify, and query
3. other common functions

If you already have rich experience using PHP, SQL, and MySQL, you can now use all these technologies
Combined. The solid integration between PHP and MySQL is only one reason why many programmers have adopted it.
The reason is that it is so simple and convenient.

1. connect PHP to MySQL

Here we fully adopt UTF-8 encoding.
Set Zend Stduio encoding: Window-> Preferences-> Workspace


Header settings to ensure that Firefox and IE are encoded in a unified manner:

 

Connect to MySQL

 

Database connection parameters can be stored using constants, so they cannot be modified and are more secure.

 

Select the database you need

 

SET the character SET. for GBK, set names gbk directly.

 

Retrieve record set

 

Output a record

 

Release result set Resources

 

Close database

 

2. add, delete, modify, and query

Add data

 

Modify data

 

Delete data

 

Show data

 '?>

III. other common functions

Mysql_fetch_row (): obtains a row from the result set as an enumeration array.
Mysql_fetch_assoc (): obtains a row from the result set as the associated array.
Mysql_fetch_array (): Gets a row from the result set as an associated array, or an array of numbers, or both.
Mysql_fetch_lengths (): Gets the length of each output in the result set.
Mysql_field_name (): obtains the field name of the specified field in the result.
Mysql_num_rows (): returns the number of rows in the result set.
Mysql_num_fields (): number of fields in the result set.
Mysql_get_client_info (): obtain MySQL client information
Mysql_get_host_info (): obtain MySQL host information
Mysql_get_proto_info (): obtain MySQL protocol information
Mysql_get_server_info (): obtain MySQL server information

Note: This article is a video tutorial from Li Yanhui PHP. This article is intended for communication purposes only and cannot be used for commercial purposes. Otherwise, the consequences will be borne by you.

Using 1.PHP to connect to MySQL 2. add, delete, modify, and query 3. if you already have rich experience using PHP, SQL, and MySQL, you can now combine all these technologies...

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.