I want a simple Php script which does the following:

(a) List all file names alphabetically such that the LAST 3 letters of the file name match with one of a few strings entered by the user at runtime
For eg, two strings PDF and TXT are specified by user at runtime, and in the directory there are 4 files: abcpdf.zip, abctxt.zip, xyzpdf.zip and xyztxt.zip
Then the script should create the following records in a mysql database:
(1) From the files abcpdf.zip and abctxt.zip, the script should extract the string 'abc' and create a record in table 'A' with the string abc as one of the fields
(2) In another table 'B' there should be one record for abctxt.zip and abcpdf.zip
This should also be done for xyzpdf.zip and xyztxt.zip, and for all files which have last 3 letters as 'pdf' or 'txt'.

At run time, upto 6 different strings (like 'pdf' or 'txt' should be specified by the user)

FOr the mysql records kindly create a generic statement of inserting data into a table, i will update that statement with the actual data required

Thanks in advance,

9 Years
Discussion Span
Last Post by diafol

What have you got so far? Put up your code so we can have a look and point you in the right direction.



Ardav, I havent coded anything as i dont know how to code in php

Josh, PDF and txt has to be a string



Well good thats easier for you then.

You need to look into PHP scandir() and PHP explode() then take a look at the mysql_() functions.

This will basicly tell you what you need to know.



Come on fella, you gotta do some work yourself. This ain't no charity. Help fair enough, but don't expect people to do all the work for you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.