Home >Backend Development >PHP Tutorial >The sixth day of learning PHP in ten days_PHP tutorial

The sixth day of learning PHP in ten days_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:08:141022browse

Learning purpose: Learn to add, delete and modify data

mysql_query($exec);
This statement alone can perform all operations, the difference is the $exec sql statement

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

At this point we have to talk about form and php variable transfer. If an
form in the form If it is submitted by POST, then you can use $_POST['item1'] to get the variable value when processing the form file. Similarly, if it is submitted by GET, it is $_GET['item1']

Isn't it very simple? But usually $exec will have problems, because your SQL statement may be very long, and you will miss the .connection character, or ' to surround the character field.
We can comment out the mysql_query($exec); statement and use echo $exec; instead to output $exec to check the correctness. If you still can't detect any errors in $exec, you can copy this sql statement and execute it in phpmyadmin to see its error message. It should also be noted that we should not use some sensitive strings as field names, otherwise problems may occur, such as date. Sometimes it is good for you to follow some rules when naming variables and fields. Beginners should not ignore its importance.

That’s it for today. You can DOWN a reference manual for SQL statements and study it further. Let’s continue talking about SESSION tomorrow.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314917.htmlTechArticleLearning purpose: Learn to add, delete and modify data mysql_query($exec); This single statement can perform all operations , the difference is that the $exec sql statement is added: $exec="insert into...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn