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