PDA

View Full Version : read / write to a file


sarah
10-10-2002, 06:28 PM
Hi

How do you read / write to a file using php?
I have an excel sheet which has Five columns.

ID Number | Name | Description | Image | Selected

I have various products for which I have ID numbers, product names, product descriptions, product images, and selected - (this is if a product has been selected). The default value of selected is always "0".

I want to read the excel sheet when the PHP page is loaded and enter the data from the excel sheet into the PHP page.

E.g

Products page will have 10 images of products available. A user selects the first product and clicks "Next". On the next page only the selected products' details will show up (ID number, Product Name, Product Description and the image of the Product).

Is this possible or do I have to export the file into a text file? If I have to export into a text file, can I still achieve this using a text file?

Also if a product is selected and the user proceeds with the transaction, I don't want any other user to be able to select the same product. Is it possible to write to the excel/text file and update the value of selected to = "1", so that when the user or any user refreshes the products page, the excel/text file is read and data of products with selected value="0" are only entered into the PHP page. (Have I confused anyone yet? - LOL)

Any examples, urls that u guys can point out to me will be greatly appreciated.

Thanks
Luv Sarah

Spookster
10-10-2002, 10:14 PM
Do you have access to a MySQL database? That would make your life much easier when trying to do this.

sarah
10-11-2002, 09:06 AM
No, unfortunately I don't.

Alekz
10-11-2002, 09:38 AM
If Your PHP is on a Windows host, with MS Office installed then check this one:
http://www.samoun.com/alain/excel/
Could also check this:
http://www.phpclasses.org/browse.html/package/237.html
But it concerns XLS file generation from PHP...

Alex

sarah
10-11-2002, 10:08 AM
Thanx Alex, I'll check it out!

sarah
10-11-2002, 10:57 AM
Hi Alex,

The PHP is hosted on an Apache running Linux. I guess the above examples u pointed out to ain't gonna work. Do u know of any examples that might work with the setup I have got?

Thanx
Sarah

Alekz
10-11-2002, 11:41 AM
No, sorry...
If You can control the way excell sheet is saved, try to save it in CSV format - Excell reads it just as XLS, but it's a textual format, so PHP will be able to read it too...

Alex