Php insert into - need a solution!

Hai people!


$query = "INSERT into people VALUES ('12/14/2010', 'NY','[B]$related[/B]')";

My problem is, i just want to insert above array contents at the bold spot shown.
i just want all people names inserted by comma seperated there:rolleyes:

Pls help.

Edited : sorry i forgot to mention one improtant thing.
in actual, the number of eliments in the arrry is unknown. its like $related[$n] in actual. can contain any number of names.

May I first suggest a table redesign. If you have a second table with a related person in each row, and the ID of the row in the table above. To add a related person, simply add a row in the second table with that person’s ID as the related person field. For a person to be related to many items, again just have multiple rows with that person’s ID.

That way would be much easier to access and manipulate data.

But if you want to keep the existing design:

$relatedList = implode("', '", $related);
$query = "INSERT into people VALUES ('12/14/2010', 'NY','{$relatedList}')";

awesome thanks! i just preferred implode :slight_smile: