LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Search page (filenames only) (https://www.linuxquestions.org/questions/programming-9/search-page-filenames-only-212011/)

javamdk 07-31-2004 11:43 PM

Search page (filenames only)
 
Hey guys... here is my scenero so far.

I have a PHP script that has a login page -- once loged in... it connects to an FTP directory which runs in the background. This allows uploads for files... only .doc and .pdf files. I do have a delete fuction, download function, logoff, and view function. Some don't work yet lol but that's something later to work on.

ANYWAYS... these uploaded files are stored into a directory called /store. What I want is to have another PHP script 'search' in the /store dirctory. I don't think it's that hard, but then again I'm kind of new to PHP so who knows.

The search would be rather basic actually... one part could be a string search for the filename (NOT any of the body) and another search part with a drop down menu for selected searches (like look for a filename with the letters BA).

Any help on how to do this? Will this be easy, hard? Helllp

Thanks -JoeY

PS: lol if someone like wants to do this for me, i'll pay (that's pretty sad but probably would if I get tired of trying this)

Cedrik 08-01-2004 01:51 AM

Here is a little example for search (it is a way, it exists probably others to do the same thing)

PHP Code:

<?php
$search_string 
".pdf";
$search_dir "/store";

$dir opendir$search_dir );
while ( (
$file readdir($dir)) != false ) {
        
/*
                preg_match("/.../", ...) : search case sensitive
                preg_match("/.../i", ...) : search case insensitive
         */
        
if (preg_match("/$search_string/i"$file) ) {
            echo 
"$file matches <BR>\n";
        }
}
closedir($dir);
?>


javamdk 08-01-2004 02:26 AM

Yeah, that does work... but it's generic in a sense. I need some kind of form that will have a drop down menue that will say, "Do you wish to find", Business Administration, Math and Science, etc.

When you click on for example Business Admin... it would look for BA in the text; just defined things. Then it will hunt out all the filenames with BA and echo them out. Then when it's echoed out... I want it to have the link to the files so they can open them up.

Any ideas?

Thanks :)


All times are GMT -5. The time now is 08:31 AM.