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] Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/ 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. Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185502 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() } ?> Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185512 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. Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185547 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. Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185663 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() } ?> Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185694 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 Link to comment https://forums.phpfreaks.com/topic/38635-read-excel-file-and-post-the-data/#findComment-185742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.