RE: [PHP-DB] CSV TO MYSQL

From: Date: Tue, 28 Aug 2001 03:44:22 +0000
Subject: RE: [PHP-DB] CSV TO MYSQL
Groups: php.db 
Request: Send a blank email to php-db+get-11870@lists.php.net to get a copy of this message
Don't forget you can just as easily replace the ; with any character you may be separating the email addresses using (for instance a comma) Ryan -----Original Message----- From: Chris Hobbs [mailto:chobbs@silvervalley.k12.ca.us] Sent: Monday, August 27, 2001 11:16 PM To: PHP-DB List Subject: Re: [PHP-DB] CSV TO MYSQL How about this: <?php $emailstring = "me@my.com;this@that.com;let@this.com"; @emails = explode(";", $emailstring); foreach($emails as $email) { echo "INSERT INTO news VALUES('$email');\n"; } ?> Rupert wrote: > Ok, this is my issue - hope someone can help. Suppose I also need to get > this out of the way too - I am a Newbie (god..I hate that word...but it's > true.....grin!) > > Anyway, I have a list of email address that I want to dump into a database > called (news) - eg. > me@my.com > this@that.com > let@this.com > there@here.com > etc.. > I separated them with (;'s) like so - me@my.com; this@that.com; > let@this.com; there@here.com; etc.. > (I suppose I could use commas instead - no prob there) > This is what I want to accomplish: > Each email address is a separate entry that needs to be downloaded into the > database. > Just like this: > # -------------------------------------------------------- > # > # Table structure for table 'news' > # > CREATE TABLE news ( > email char(255) NOT NULL, > PRIMARY KEY (email), > UNIQUE email (email) > ); > # > # Dumping data for table 'news' > # > INSERT INTO news VALUES ( 'me@my.com'); > INSERT INTO news VALUES ( 'this@that.com'); > INSERT INTO news VALUES ( 'let@this.com'); > INSERT INTO news VALUES ( 'there@here.com'); > INSERT INTO news VALUES ( 'etc..'); > ------------------------------------------------------------ > I have a script that gets me to this point: > INSERT INTO news VALUES (,"me@my.com"," this@that.com"," > let@this.com","there@here.com","etc.."); > But that is not what I want. I can attach the script for analysis or if > anyone has a better idea. I would appreciated it very > much. Thanks.. > Rupert > > > > > -- Chris Hobbs Silver Valley Unified School District Head geek: Technology Services Coordinator webmaster: http://www.silvervalley.k12.ca.us/~chobbs/ postmaster: chobbs@silvervalley.k12.ca.us -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#11870) next »