Jump to content

[SOLVED] modifying function


jakebur01

Recommended Posts

How can I modify this function to get only a list of image urls stored in a db rather than just getting ALL the images in a directory?

 

Example: something like: SELECT image_file_name FROM image_table WHERE `Username` = '$_SESSION[user]';

and store this list of file names into the array in the function below rather than just getting all the files in the directory.

 

#-#############################################
# desc: gets the list of image files in the directory
# param: [optional] directory to look through
# returns: array with alphabetically sorted list of images
function GetFileList($dirname="."){
global $config;
$list = array(); 

if ($handle = opendir($dirname)) {
	while (false !== ($file = readdir($handle))) {
		//this matches what type of files to get. jpeg, jpg, gif, png (ignoring case)
		if (preg_match("/\.(jpe?g|gif|png)$/i",$file)) { 
			$list[] = $file;
		} 
	}
	closedir($handle); 
}
sort($list);

return $list;
}#-#GetFileList()

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/148180-solved-modifying-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.