jcm Posted February 15, 2007 Share Posted February 15, 2007 First I need to read all the ".gif" in the folder and then take the name of that file and search that name and match it up from data in a column in Excel (that has product description, price, item number...etc). How can this be done? I am new to php. But not new to the industry (9 years experience). [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
php_joe Posted February 15, 2007 Share Posted February 15, 2007 can you save the database as a csv (coma separated value) file? You can still open, modify, and save it using Excel, but this way php can read it as a text file. Quote Link to comment Share on other sites More sharing options...
php_joe Posted February 15, 2007 Share Posted February 15, 2007 you can open a csv file like this: <? $file = "./database.csv"; $row = file($file); // get the rows foreach($rows as $key => $row_content){ // loop through the rows $cell = explode(',', $value); // break the row up into cells // place code for matching data to a particular cell, such as eregi() } ?> Quote Link to comment Share on other sites More sharing options...
mbtaylor Posted February 15, 2007 Share Posted February 15, 2007 I have had experience reading and writing to excel files. I highly recommend the use of the PEAR excel_writer class which is freely available from the PEAR website. Theres good documentation to it and its pretty easy to use. Use the directory iterator to loop through your directory looking for gif files etc then use the http://pear.php.net/package/Spreadsheet_Excel_Writer class to look through the excel file. Quote Link to comment Share on other sites More sharing options...
jcm Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks for the help guys. I will test it and let you know. Quote Link to comment Share on other sites More sharing options...
jcm Posted February 15, 2007 Author Share Posted February 15, 2007 Error: Warning: Invalid argument supplied for foreach() in test.php on line 4. What do I need to put down? <?php $file = "./Item Descriptions.csv"; $row = file($file); // get the rows foreach($rows as $key => $row_content){ // loop through the rows $cell = explode(',', $value); // break the row up into cells // place code for matching data to a particular cell, such as eregi() } ?> Quote Link to comment Share on other sites More sharing options...
TreeNode Posted February 15, 2007 Share Posted February 15, 2007 Maybe your problem: $row = file($file); // get the rows foreach($rows as $key => $row_content){ // loop through the rows Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.