10 days to learn the sixth day of PHP _php

Source: Internet
Author: User
Keywords learn EXEC ITEM1 statement can form _post
Learning Purpose: Learn to add delete modification data

mysql_query ($exec);
Single This statement can do all of the operation, the difference is $exec this SQL statement

Added: $exec = "INSERT INTO tablename (ITEM1,ITEM2) VALUES ('". $_post[' item1 ']. "',". $_post[' item1 ']. ")";

Delete: $exec = "Delete from tablename where ...";

Modified: $exec = "UPDATE tablename set item1= '". $_post[' item1 ']. "' Where ... ';

Speaking of which, we need to talk about the form and the PHP variable pass, if one of the forms
The form is submitted as a POST, then the form file can be processed using $_post[' item1 '] to get the value of the variable, and the same as get submitted is $_get[' item1 ']

Isn't it simple? But usually $exec can be problematic because your SQL statements may be long and you'll miss them. Connectors, or ' to surround a character field.
We can annotate mysql_query ($exec); The statement uses the Echo $exec, instead of outputting the $exec to check for correctness. If you are not aware of any errors in $exec, you can copy this SQL statement to phpMyAdmin to see if it has an error message. It is also important to note that we do not use sensitive strings as field names, or there are likely to be problems, such as date or something. The name of the variable, the name of the field follows a little regularity sometimes it is a benefit to oneself, the beginner should not neglect its importance.

Today, you can down a reference manual for a SQL statement, and then study the study. Go ahead and say the session tomorrow.
  • Related 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.