INSERT data statement in Php

Source: Internet
Author: User
To save data to the mysql database, we need to use update or insert to help us complete the process. below I will introduce several application examples to my friends who are learning php. I hope the article will help you. let's first introduce INSERT statement syntax 1: INSERT... to save data to the mysql database, we need to use update or insert to help us complete the process. below I will introduce several application examples to my friends who are learning php. I hope the article will help you.

Let's first introduce the INSERT statement.

Syntax 1: Insert into table_name VALUES ("1", "2 ")

Explanation2 values are inserted. The first value is 1 and the second value is 2.

Statement 2: Insert into table_name (column1, column2) VALUES (value1, value2)

Note: insert the specified value based on the specified key. The value of the column1 plug-in field is value1, and then the value of the column2 field is value2.

The code of the INSERT statement is as follows:

 

The code is as follows:

/** Data retention * Program: Liu Xing * Time: 2010-6 */        
 $ Value) {if (strstr ($ key, "fs") {if (strstr ($ key, "kfs") {$ khxm = substr ($ key, 3, strlen ($ key)-3); $ fs = $ zl [$ key]; continue;} // www.phprm.com else {$ khxm = substr ($ key, 2, strlen ($ key)-2);} $ khfs = $ value; $ khinfo = $ zl [$ khxm]; $ SQL = "delete from khzl where peopleid = '$ pid' and khbm = '$ khxm' and time = '$ jd' and year = '$ year '"; $ result = mysql_query ($ SQL); $ SQL = "INSERT INTO khzl (peopleid, khbm, fenshu, time, year , Info, fs) VALUES ('$ pid', '$ khxm', $ khfs, '$ jd', '$ year',' $ khinfo ',' $ Fs ') "; $ fs = 0; $ result = mysql_query ($ SQL) ;}}?>    
 "; Echo" location = 'Your lexz. php'; "; echo" script ";    

Php entry network reminds you that when saving data, we should pay attention to the encoding between pages to avoid unnecessary troubles, in addition, the data type must be consistent with the data submitted. Otherwise, the data cannot be saved.


Article address:

Reprint at will ^ please include the address of this article!

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.