Open a text file using php to append a mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

Open a text file using php to append a mysql database

Post 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:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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
(#10850)
lordrt
Forum Commoner
Posts: 34
Joined: Sun Jul 19, 2009 11:44 pm

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

Post by lordrt »

thx for the links :drunk:
Post Reply