单个插入查询以在一列中插入多行

I am trying to make a query that will insert multiple values from my form into a single row in my table.

 $q2="INSERT INTO tbl_Answer('Answer')VALUES ('$A1'),('$A2'),('$A3'),('$A4'),('$A5')";

Everything I have found tells me this should work using PHP with a MySQl database. Any ideas if I have done something wrong with the syntax or where my issue is? Thanks

We might need more information however a couple of things:

  • If you are using mysql in unix based system tables are case sensitive.
  • Second, should you use ` instead of ' on the name of your columns?(and i would say they are both innecesary) like:

    INSERT INTO tbl_Answer(`Answer`) or even better INSERT INTO tbl_Answer(Answer)

You need more fields in your table. You should have a field for each of your variables.

You have a minor problem with your query syntax.

$q2 = "INSERT INTO tbl_Answer
        ('A1', 'A2', 'A3', 'A4', 'A5')
       VALUES
        ('$A1', '$A2', '$A3', '$A4', '$A5');";
INSERT INTO tbl_Answer (Answer) VALUES ('$A1'),('$A2'),('$A3'),('$A4'),('$A5')

Is the same as saying:

INSERT INTO tbl_Answer (Answer) VALUES ('$A1')    
INSERT INTO tbl_Answer (Answer) VALUES ('$A2')
INSERT INTO tbl_Answer (Answer) VALUES ('$A3')
INSERT INTO tbl_Answer (Answer) VALUES ('$A4')
INSERT INTO tbl_Answer (Answer) VALUES ('$A5')

What exactly are you looking for?

Here is a demo of your original query working: http://sqlfiddle.com/#!2/e20fc/1

Looks like the value of $A1-$A5 is throwing the query off. Are you receiving any error?