0

I'm doing php and came across the following problem: How to register multiple sequence data from a textarea?

My idea is to get the text from a textarea of a form via the POST method. And the text in question follow the following pattern:

Name 01, 01 Phone, Address 01 
Name 02, 02 Phone, Address 02 
Name 03, 03 Phone, Address 03

Each row contains information of a client and the commas will separate the data from the customer master record, I want each client to be registered with a different ID in the database (taking into account that later can be edited separately).

I know as more or less as separate data line, but how to do this by separating comma?

I appreciate the help of those who have to help me in this matter and I apologize for my bad English.

Bruno
  • 23
  • 3
  • possible duplicate of [php split string](http://stackoverflow.com/questions/5159086/php-split-string) – Wrikken Aug 03 '11 at 19:01

1 Answers1

1

One really primitive way is to do it by this:

$rows = explode("\n",$_POST['text']);
foreach($rows as $row)
{
    $client = explode(",",$row);

    $query = "INSERT INTO...". $client[0] ."..." . $client[1];
}

Of course, sanitize it.

georgehs
  • 11
  • 1