Jump to content

Inserting array values in table


ITStudent

Recommended Posts

[!--quoteo(post=345456:date=Feb 13 2006, 02:43 PM:name=ITStudent)--][div class=\'quotetop\']QUOTE(ITStudent @ Feb 13 2006, 02:43 PM) [snapback]345456[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Is it possible to insert the values of an array into a table, with each value being stored in a new row.

I need to take the value of the array select information from a table based on this and then insert to the second table.

Thanks.
[/quote]

i'm not sure i follow what you're asking. the simple answer to your question is yes, you can store each value in an array in a new row. something like this is all you need:
[code]
<?php
$q = "INSERT INTO tableName (colName) VALUES ";
foreach ($array as $value)
  $q .= "('$value'), ";

$q = substr($q, 0, strlen($q) - 2);
mysql_query($q);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.