Re: [PHP4BETA] importing a text file into a database
| From: | David Robley | Date: | Thu, 09 Mar 2000 02:03:26 +0000 |
| Subject: | Re: [PHP4BETA] importing a text file into a database | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11781@lists.php.net to get a copy of this message | ||
On 8 Mar, mike@stratabase wrote:
> I have a list of email addresses
>
> ie:
>
> mikey@whatver.com
> johnny@whoever.com
> wendy@whereever.com
> mrEd@horseyfarm.com
> etc...
>
>
> I need to import these emails (total of 700 and some) into a database,
> but each email has to be entered seperately into its own row... so the
> database has a field in it called email and i need to import all these
> emails so that they will be entered under their own row. Any ideas??
> i want a better solution than having to enter them in one by one(of
> which i have a form that does it one by one i need a form that will
> enter the whole list as if it was entered one by one) sorry about the
> confusing way ive wrote this but its the best i can do . If anyone can
> help that would be great!
>
> Mikey T
First, could you tell Outhouse to wrap lines at around 72 chars? Ta.
Now, if you are using MySQL, there is a MySQL function (command,
syntax?) LOAD DATA INFILE which will allow you to to just what you want.
Failing that, the technique would go something like:
open the file
for each line
insert value into db
end for
close the file
The code would probably take about twice as many lines....
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA