The sixth day of learning php in ten days. Objective: to learn how to add or delete the modified data mysql_query ($ exec). you can execute all the operations with this statement. The difference is that the SQL statement $ exec is added: $ execinsertinto. objective: learn to add, delete, and modify data
Mysql_query ($ exec );
This statement can execute all the operations. The difference is that the SQL statement $ exec
Add: $ exec = "insert into tablename (item1, item2) values ('". $ _ POST ['item1']. "',". $ _ POST ['item1']. ")";
Delete: $ exec = "delete from tablename where ...";
Modify: $ exec = "update tablename set item1 = '". $ _ POST ['item1']. "'Where ...";
Let's talk about the transfer of form and php variables. if
If the form is submitted in POST mode, you can use $ _ POST ['item1'] to obtain the variable value for processing the Form File. Similarly, $ _ GET ['item1'] is submitted in GET mode.
Is it easy? But usually $ exec will have a problem, because your SQL statement may be very long, you will miss the. connector, or 'to enclose the character field.
Note mysql_query ($ exec); the statement uses echo $ exec; instead of $ exec to output $ exec to check whether the statement is correct. If you do not notice any error in $ exec, you can copy the SQL statement to phpmyadmin to check its error information. Note that we should not use sensitive strings as field names. otherwise, problems may occur, such as date. Variable naming: Field naming follows a certain rule. sometimes it is good for you. beginners cannot ignore its importance.
Let's talk about it today. you can go DOWN a reference manual for SQL statements and study it again. Continue to talk about the SESSION tomorrow.
Mysql_query ($ exec); you can execute all the operations with this statement. The difference is that the SQL statement $ exec is added: $ exec = "insert...