About MySQL adding data, what to do with

Source: Internet
Author: User
About MySQL Add data
INSERT into Roomid,name,id1,id2 values (' 1 ', ' 232 ', ' $_post[id1] ', ' $_post[id2] ')

$_POST[ID1],$_POST[ID2] Pass over is the value, not the ID, how to deal with it here?

------Solution--------------------
$_POST[ID1],$_POST[ID2] is the concept of how a value is not an ID.

is not the value in SQL is the variable name, not the value AH.
INSERT into Roomid,name,id1,id2 values (' 1 ', ' 232 ', ' {$_POST[ID1]} ', ' {$_post[id2]} ')

Or

INSERT into (ROOMID,NAME,ID1,ID2) VALUES (' 1 ', ' 232 ', ' ". $_post[id1]." ', ' ". $_post[id2]." ') "
------Solution--------------------
What do you mean??
------Solution--------------------
The IDs of the two tables cannot be inserted at the same time in an INSERT statement, and should be done in step.
If the ID is set to Auto_increment, then no ID is inserted, and duplicate values cannot be interpolated.
If not set to self-growth:
sql = "INSERT into the Roomid,name,id1" values (". $_post[' Roomid ').", ' ". $_post[' name ']." ', ". $_post[' Id1 '].") ";
When querying, you can do multiple table queries.

------Solution--------------------
$_POST[ID1],$_POST[ID2] It was his value.
  • 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.