Vincent Canales Vincent Canales - 2 years ago 69
SQL Question

PHP: Insert data in MySQL every after the comma is detected



John, Doe, Jane

Hi, This is a message

How can i save each data with the name separated with comma in database? output must be.

Name | Message
John | Hi, This is a message
Doe | Hi, This is a message
Jane | Hi, This is a message

Answer Source

Use explode function to explode and foreach to insert

 $names_all="John, Doe, Jane";
 $msg = 'Hi, This is my msg';
 foreach($names as $name)
             //insert query using $name and $msg
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download