I was actually able to find a post by another user here which lead me in the right direction. I haven't bookmarked it but i will as soon as i have a bit of time. Meanwhile, here is the solution to my problem:
<form name="search-form" onclick="this.form.submit()" id="search-form" method="post">
<input size="30" name="search" type="text" id="search" />
<input class="button" type="submit" name="stylesearch" value="search" />
</form>
<?php
if(isset($_POST['stylesearch']))
{
$search = $_POST['search'];
if (@get_magic_quotes_gpc())
{
$search = stripslashes($search);
}
$it = new RecursiveDirectoryIterator("galleries");
$allowed=array("jpg");
foreach(new RecursiveIteratorIterator($it) as $file) {
if (false !== stripos($file, $search))
{
echo 'You have searched for the following '.$it.' style(s): <a href="'. $file . '" target="">'.str_replace(array(' - ','.jpg'), array(' '), $search).'</a>' . "<br>";
}
}
echo " ";
}
else
{
echo "<p>search a style</p>";
}
?>
Here is the problem:
I have a "gallery/" folder which contains multiple sub-folders that go a few levels deep. I have successfully made inventory of all jpgs contained in all subfolders, in a nice list with direct links to the pictures. That's the easy part.
What i'd like to do is to have an input box where i can type a term, and upon clicking Submit, only the files that contain that term in the file name will show up in the list.
I have created the input button, and when you click it it shows the entire list (meaning it simply runs the code as it is supposed to run). For the life of me, i can't understand how to make it work in a way that it will show only the files matching what i type in the $search field.
Is what i am trying to do even possible?
Here is the code:
<form action="searchlist.php" method="post"><input name="searchstyle" id="searchstyle" type="search" value=""><button
name="stylesearch" id="stylesearch">style search
'.str_replace(array(' - ','.jpg'), array(' '), $file).'' . "
"; } else{ $dirs[]=$dest; } } } } return $files; } printAll(getcwd()); } ?>