How to use the Insert Into data insert statement of PHP+MySQL
This article mainly shows you the "PHP+MySQL Insert Into data insertion statement how to use", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "PHP+MySQL Insert Into data insertion statement how to use" this article.
The details are as follows:
The INSERT INTO statement is used to insert new records into the database table.
Insert data into a database table
The INSERT INTO statement is used to add new records to the database table.
Syntax:
INSERT INTO table_nameVALUES (value1, value2,....)
You can also specify the columns in which you want to insert data:
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)
Note: SQL statements are not case-sensitive. INSERT INTO is the same as insert into.
In order for PHP to execute this statement, we must use the mysql_query () function. This function is used to send a query or command to a MySQL connection.
Example:
In the previous section, we created a table called "Persons" with three columns: "Firstname", "Lastname", and "Age". We will use the same table in this example. The following example adds two new records to the "Persons" table: