Hello everyone,
Ive created a little script that looks in a directory to specify and then gerts the file names and throws those into a database
now, im modifying the script, but not to sure on what I should do.
Im trying to specify a directory called PhotoLab
now there are alot of sub directories here
I can get the first directory (PhotoLab)
but how will I get the sub directory and its contents
<?
include('cfg.php');
$handle = opendir ('C:\\Inetpub\\wwwroot\\photolab\\');
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..' && $file != 'index.php' && $file != 'cfg.php') {
//Check new entry against records in db
$filter = $file;
$filter = "midi/80/$file";
//echo "<a href='C:\\Inetpub\\wwwroot\\photolab\\$file'>$file </a><br>";
$connect = mysql_connect($db_connetion, $db_username, $db_password) or die ("Couldnt connect");
$db = mysql_select_db($db_databse, $connect) or die ("Couldnt open Database");
$check_query = mysql_query("SELECT * FROM wml WHERE wml_text='$file' AND wml_link='$filter' ");
if (mysql_num_rows($check_query) == 0) {
//Do insert only if record does not yet exist
$query = mysql_query("INSERT INTO wml (wml_text,wml_link,wml_cat) VALUES ('$file','$filter','80')");
echo "Merging into Database: $file<br>";
} else {
echo "Already in Database: $file<br>";
}
}
}
closedir ($handle);
mysql_close($connect);
?>
now this script works great for only one folder an no subfolders
im trying to make it so I can get the filenames and location into a databse example:
PhotoLab
PhotoLab/John
PhotoLab/John/2001
PhotoLab/John/2002
PhotoLab/Christy/2000
PhotoLab/Christy/2001
PhotoLab/Don/2000
etc...
there could be more subdirectories than that also
in each folder there all .jpg files
any ideas?
now this is a s