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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.