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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

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

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

do you have access to the database?

If so export file as a csv file then import it into the database
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

oo i never tried that before. thanks. i will give it a shot.
User avatar
will83
Forum Commoner
Posts: 53
Joined: Thu Nov 10, 2005 3:13 pm

Post by will83 »

It worked spot on, thanks
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

no worries.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post 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);
?>
Post Reply