1. SQL statements Used
INSERT into table name (field list) VALUES (list of values), (value list) ...;
Attention:
1), the field list to correspond to the Value List 2), when inserting data into all the fields in the table, you can omit the field list
2. Example:
<?PHP//insert data into table//Include connection database file (two methods, require is more strict than include, if the path is not reported serious error)//include ' conn.php '; require' Conn.php '; //Assemble SQL statements that insert data $sql= "INSERT into students (STUNAME,STUSEX,STUBIRTH,CLASSID) VALUES (' Tom1 ', default, ' 1987-05-08 ', 1)"; //$sql = "INSERT into Test (STUNAME,STUSEX,STUBIRTH,CLASSID) VALUES (' Jane ', default, ' 1988-05-08 ', 2), (' Nancy ', 0, ' 1999-5-12 ', 3) "; Execute SQL statement if(mysql_query($sql)){ Echo"<br> Insert Data Success"; }Else{ Echo"<br> failed to insert data"; } //To close a database connection Mysql_close($link);?>
PHP Note seven: PHP operation MySQL table (insert data)