This topic is locked

Reading a Flat File

10/23/2007 4:21:53 PM
PHPRunner General questions
jimhnet author

I am currently trying to simplify updating of members who pay with a credit card.
Right now I manually download the settlement report(authorize.net) in an excel format and kick out the columns

I don't need and then use phpmyadmin to upload to a working table which I continually process

from, match by email address the member and create a transaction record referenced to the

member master table.
Is there anyway I can read the data directly from the downloads into a table.
Thanks
Jim Freeman

A
alang 10/24/2007

One way is to use some PHP code to read the file directly, process records into fields and insert into your database.
Basic structure might look something like this:
$fps = fopen($srcfile,"r")

while(!feof($fps))

{

$lin = fgets($fps);

$flds = explode(",",$lin)

..

SQL insert into your table using $flds[0], $flds[1]... etc

..

}

fclose($fps);