954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

script to display list of files with a particular string matching,plus a few things

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

arvindikchari
Light Poster
41 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

Josh Connerty
Posting Whiz
342 posts since Apr 2009
Reputation Points: 31
Solved Threads: 27
 

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

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

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

arvindikchari
Light Poster
41 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Josh Connerty
Posting Whiz
342 posts since Apr 2009
Reputation Points: 31
Solved Threads: 27
 

@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.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You