Re: loading data into mysql from txt file from php
| From: | mike cullerton | Date: | Tue, 03 Jul 2001 21:18:50 +0000 |
| Subject: | Re: loading data into mysql from txt file from php | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56063@lists.php.net to get a copy of this message | ||
write a script that reads in each line of the file, uses split() to break
the line up at the tabs, and then inserts into the database.
$data_array = split([tab],$file);
$query = "insert into table values ($data_array[0], $data_array[1],...)
you'll have to look up the regular expression for tab and use it where i
wrote [tab] in the split() command
on 7/3/01 3:02 PM, Clif Wieden at cwieden@capecod.net wrote:
> I have a project where the admin uploads a new data file and it needs to
> be loaded into a mysql database. What's the best way to do this? The
> data file is tab-delimted but could be reformatted.
>
> Right now the file is uploaded and after copy($new_file, $file_loc)
> would like to refresh the db.
>
> unix box running php4 and mysql 3.22 and of course apache
>
> Thanks in advance,
> clif
>
-- mike cullerton michaelc@cullerton.com