Hi,
I had problem with inserting array values into table specific columns.Like
$abc=(asfh,adsf,afdaf);
I want to insert these three elements in a table in a different columns in a single loop..
foreach($content as $value)
{
$insert="INSERT INTO test(username,passowrd) VALUES ('$value')";
mysql_query($insert);
}
I tried above code it is not working...
How do I Insert array into specific table columns
Moderator: General Moderators
Re: How do I Insert array into specific table columns
No, you don't. You actually want to insert those three elements into a table in one query. Assuming, that is, that you aren't talking about three separate rows in the table each with only one bit of data in only one column.varma457 wrote:I want to insert these three elements in a table in a different columns in a single loop..
You can do
Code: Select all
INSERT INTO table (field1, field2, field3) VALUES (data1, data2, data3)Code: Select all
INSERT INTO table SET field1=data1, field2=data2, field3=data3Code: Select all
INSERT INTO table (fields) VALUES (first set of values), (second set of values), (third set of values)