Page 1 of 1

Open a text file using php to append a mysql database

Posted: Sun Jul 19, 2009 11:55 pm
by lordrt
Hello all
am new to php and have to do the following:
1. open a text file containing csv values using php
2. read each content line-by-line
3. for each line read, do the correspoding operation on the mysql db: insert/update/delete in specific table in batch mode
4. return another csv file from the mysql table

Point 3 should be done in the php code itself.

can anyone plz help? :banghead:

Re: Open a text file using php to append a mysql database

Posted: Mon Jul 20, 2009 12:06 am
by Christopher
There are many good code examples in the manual:
lordrt wrote:1. open a text file containing csv values using php
2. read each content line-by-line
http://us3.php.net/manual/en/function.fgetcsv.php
http://us3.php.net/manual/en/function.str-getcsv.php
lordrt wrote:3. for each line read, do the correspoding operation on the mysql db: insert/update/delete in specific table in batch mode
Depending on you server:
http://us3.php.net/manual/en/book.mysql.php
http://us3.php.net/manual/en/book.mysqli.php
http://us3.php.net/manual/en/book.pdo.php
lordrt wrote:4. return another csv file from the mysql table
http://us3.php.net/manual/en/function.fputcsv.php

Re: Open a text file using php to append a mysql database

Posted: Mon Jul 20, 2009 2:52 am
by lordrt
thx for the links :drunk: