Hello,

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,
Arvind

Does pdf and txt have to be as a string or jumbled up chars?

Member Avatar for diafol

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

Hello

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

Josh, PDF and txt has to be a string

Regards
Arvind

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.

Member Avatar for diafol

@Arvin

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.