Page 1 of 1

Pulling rows from a textbox and insert each row as a new dat

Posted: Thu Mar 02, 2006 6:41 am
by will83
Hi as above,

I am creating a bulk e-mail sender to send e-shots to our clients.

I have many e-mail address in excel and want to simply copy and paste them into a form textarea field and use php to insert each email address into a database.

Any info or method suggestion appreciated!!

Thanks

Will

Posted: Thu Mar 02, 2006 6:52 am
by phpScott
do you have access to the database?

If so export file as a csv file then import it into the database

Posted: Thu Mar 02, 2006 7:28 am
by will83
oo i never tried that before. thanks. i will give it a shot.

Posted: Thu Mar 02, 2006 8:41 am
by will83
It worked spot on, thanks

Posted: Thu Mar 02, 2006 9:16 am
by phpScott
no worries.

Posted: Thu Mar 02, 2006 9:47 am
by jayshields
If someone is looking at this thread for a solution which I would expect was needed before reading the actual question.

Something like this would work:

Code: Select all

<?php
  $lines = array();
  $lines = implode("\n", mysql_real_escape_string($_POST['thetextarea']));

  $query = "INSERT INTO `sometable` (`line1`, `line2`, `line3`) VALUES ('$lines[1]', '$lines[2]', '$lines[3]')";
  mysql_query($query);
?>