How pick up value depending on the query

i have a drop downl list which the value comes from mysql now i have this query $album = 0 so it only accepts the option value =“0”

this way works
<option value=“0”>

function upload_files ($save_dir = ‘’, $album = 0)

because value album is = to 0 and picks up value 0 from the drop down menu

how can i change to pick up something like this??
<option value=“’ .$value[‘album_id’]. '”>

i tried
$album = ’ ')
but did not work

It could be on the main page. Look for upload_files, but without function in front of it. Something like the example I posted, or something like


if (upload_files($dir, $value['album_id'])) { 

definetly not this one??? cz i have alot of those if statments and i always made changes tru in here

<?php
/**
* create a sub album directory for photos
* to be stored in
*/
function create_album ($album_name, $sub_album = 0)
{
	global $db;

	$sql = "INSERT INTO " .ALBUMS_TABLE. "
		(
			album_name,
			sub_album
		)
		VALUES
		(
			'" .addslashes($album_name). "',
			" .intval($sub_album). "
		)";

	if ($db->query($sql))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/**
* get a list of sub albums
*/
function get_albums ($sub_album = 0)
{
	global $db;

	$sql = "SELECT *
		FROM " .ALBUMS_TABLE. "
		WHERE sub_album = " .intval($sub_album);

	$db->query($sql);

	// initialise album storage
	$albums = array();
	while ($row = $db->fetch())
	{
		$albums[] = $row;
	}

	return $albums;
}

/**
* get a list of photos within an album
*/
function get_photos ($album = 0)
{
	global $db;

	$sql = "SELECT *
		FROM " .PHOTOS_TABLE. "
		WHERE album_id = " .intval($album). "
		ORDER BY photo_id ASC";

	$db->query($sql);

	// initialise album storage
	$photos = array();
	while ($row = $db->fetch())
	{
		$photos[] = $row;
	}

	return $photos;
}

/**
* get a large version of a particular photo
*/
function get_large ($photo, $album = 0, $next = '')
{
	global $db, $template, $account_details;

	// shall we get the next / previous photo
	switch ($next)
	{
		case "next" :

			$next_sql = "AND photo_id > " .intval($photo). " ORDER BY photo_id ASC";
			break;

		case "previous" :

			$next_sql = "AND photo_id < " .intval($photo). " ORDER BY photo_id DESC";
			break;

		default :

			$next_sql = "AND photo_id = " .intval($photo);
			break;
	}

	$sql = "SELECT *
		FROM " .PHOTOS_TABLE. "
		WHERE album_id = " .intval($album). "
		" .$next_sql. "
		LIMIT 1";

	$db->query($sql);
	if ($db->num_rows() == 0)
	{
		return '';
	}
	else
	{
		$photo_info = $db->fetch();

		// note the total directory
		$location = 'photos/' .$photo_info['photo_proper'];

		// now we need to resize
		list($width, $height) = getimagesize($location);
		if ($width < 300)
		{
			$new_width = $width;
			$new_height = $height;
		}
		elseif ($width > $height)
		{
			$new_width = 300;
			$new_height = $height * ($new_width / $width);
		}
		elseif ($width < $height)
		{
			$new_width = $width * ($new_height / $height);
			$new_height = 300;
		}

		// work out the next link
		$next = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=next">Next</a>';
		$previous = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=previous">Previous</a>';			

		return '<div id="largephoto"><img src="' .$location. '" height="' .$new_height. '" width="' .$new_width. '" class="large"><br /><div id="prevnext">' .$previous. ' :: ' .$next. '</div></div>';
	}
}

/**
* get an array of locations
*/
function get_locations ()
{
	global $db;

	// initialise array
	$locations = array();

	// select albums
	$sql = "SELECT

			album_id,
			album_name

		FROM " .ALBUMS_TABLE;

	$db->query($sql);
	while ($row = $db->fetch())
	{
		$locations[] = $row;
		
	}

	return $locations;
}

/**
* make the locations table
*/
function make_locations ($locs)
{
	$html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>';
	foreach ($locs AS $key => $value)
	{
	     echo 'key = '.$key.' value = '.$value.'<br />'; 
		$html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>';
	}
	$html .= '</select>';

	return $html;
}

/**
* delete an album from the database
* does not delete the photos in it
*/
function delete_albums ($album_ids)
{
	global $db;

	if (sizeof($album_ids) > 0)
	{
		$sql = "DELETE FROM " .ALBUMS_TABLE. "
			WHERE album_id IN (" .implode(',', $album_ids). ")";
	
		if ($db->query($sql))
		{
			return TRUE;
		}
	}

	return FALSE;
}

/**
* delete a set of photos
*/
function delete_photos ($photo_ids)
{
	global $db;

	if (sizeof($photo_ids) > 0)
	{
		// select photo names for deletion
		$sql = "SELECT photo_proper
			FROM " .PHOTOS_TABLE. "
			WHERE photo_id IN (" .implode(',', $photo_ids). ")";

		$db->query($sql);

		$unlink_ids = array();
		while ($row = $db->fetch())
		{
			$unlink_ids[] = $row['photo_proper'];
		}

		// now delete the photos
		if (sizeof($unlink_ids) > 0)
		{
			$sql = "DELETE FROM " .PHOTOS_TABLE. "
				WHERE photo_id IN (" .implode(',', $photo_ids). ")";
	
			if ($db->query($sql))
			{
				// remove photo from directory
				for ($i = 0; $i < sizeof($unlink_ids); $i++)
				{
					unlink("photos/" .$unlink_ids[$i]);
					unlink("photos/thumbs/" .$unlink_ids[$i]);
				}
				return TRUE;
			}
		}
	}

	return FALSE;
}

/**
* upload a set of files
*/
function upload_files ($save_dir = '')
{
	global $db;

	// check the save dir is writable
	if (!is_writable($save_dir))
	{
		return FALSE;
	}

	// specify allowed file types
	$allowed_types = array (
	
		'image/jpg',
		'image/jpeg',
		'image/pjpeg',
		'image/gif'
	
	);

	// keep a list of uploaded files
	$uploaded = array();

	// store bytes uploaded
	$total_bytes = 0;

	// go through the list of files
	while (list($key, $value) = each($_FILES['userfile']['name']))
	{
		// check file has been passed
		if (!empty($value))
		{
			// find extension
			$extension = substr($_FILES['userfile']['name'][$key], strpos($_FILES['userfile']['name'][$key],".") + 1);

			// time + $key for name
			$name = time(). "_" .$key. "." .$extension;

			// save url
			$add = $save_dir. "/" .$name;

			if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $add))
			{
				chmod($add, 0777);

				// add photo to database
				create_photo($_FILES['userfile']['name'][$key], $name, $album);
			}
		}
	}

	return TRUE;
}

/**
* insert photo details into the database
*/
function create_photo ($photo_name, $key_name)
{
	global $db;

	// get the filesize
	if (!$size = filesize("photos/" .$key_name))
	{
		$size = 0;
	}

	// insert the photo in the database
	$sql = "INSERT INTO " .PHOTOS_TABLE. "
		(
			photo_name,
			photo_date,
			photo_proper,
			photo_size,
			album_id
		)
		VALUES
		(
			'" .addslashes($photo_name). "',
			" .time(). ",
			'" .addslashes($key_name). "',
			" .intval($size). ",
			" .$album. "
		)";

	if ($db->query($sql))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/**
* get a complete raw copy of the directory
*/
function get_dir_contents ($dir)
{
	// declare content array
	$contents = array();

	// check gallery exists
	if (is_dir($dir))
	{
		if ($handle = opendir($dir))
		{
			while (FALSE !== ($file = readdir($handle)))
			{
				if ($file != '.' && $file != '..' && $file != 'thumbs')
				{
					if (file_exists($dir. '/thumbs/' .$file) || thumbnail($file, $dir. '/' .$file, $dir. '/thumbs'))
					{
						$contents[] = $dir. '/thumbs/' .$file;
					}
					else
					{
						$contents[] = 'no_image.gif';
					}
				}
			}
		}
	}

	return $contents;
}

/**
* create a thumbnail of a photo and store it
* in the thumbs directory
*/
function thumbnail ($filename, $source_file, $destination, $new_h = 75, $new_w = 75)
{
	if (!is_file($source_file))
	{
		return FALSE;
	}

	// get the image details
	list($old_w, $old_h, $type) = getimagesize($source_file);

	// create source image
	switch($type)
	{
		case 1:

			$source = @imagecreatefromgif($source_file);
			break;

		case 2:

			$source = @imagecreatefromjpeg($source_file);
			break;

		case 3:

			$source = @imagecreatefrompng($source_file);
			break;

		default :

			return FALSE;
	}

	// work out dimensions
	if ($old_w < $old_h)
	{
		$thumb_w = $new_w;
		$thumb_h = $old_h * ($new_h / $old_w);
	}
	elseif ($old_w > $old_h)
	{
		$thumb_w = $old_w * ($new_w / $old_h);
		$thumb_h = $new_h;
	}
	elseif ($old_w == $old_h)
	{
		$thumb_w = $new_w;
		$thumb_h = $new_h;
	}
	$thumb = @imagecreatetruecolor($thumb_w, $thumb_h);

	// create image
	imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h);

	// check we have a proper destination
	if (!is_dir($destination))
	{
		mkdir($destination, 0777);
	}

	// save image
	switch ($type)
	{
		case 1:
		case 2:

			imagejpeg($thumb, $destination. '/' .$filename);
			break;

		case 3:

			imagepng($thumb, $destination. '/' .$filename);
			break;
	}

	// memory saving
	imagedestroy($thumb);
	imagedestroy($source);

	// thumbnail created successfully
	return TRUE;
}

/**
* make the table to show the directories and photos
*/
function make_table ($list, $type, $row = 3)
{
	// initialize gallery html array
	$gallery_html = array();

	// check if we have a list > 0
	if ($size = sizeof($list))
	{
		switch ($type)
		{
			case "GALLERIES" :

				$gallery_html[] = '<div id="galleries">';
				break;

			case "PHOTOS" :
			case "RAW" :

				$gallery_html[] = '<div id="photos">';
				break;
		}

		// loop through list
		for ($i = 0; $i < sizeof($list); $i++)
		{
			// shall we open a new list
			if ($i % $row == 0)
			{
				$gallery_html[] = '<ul>';
			}

			// add to list
			switch ($type)
			{
				case "GALLERIES" :

					// create the delete link
					$delete_link = '';
					if ($_SESSION['logged_in'])
					{
						$delete_link = '[ <a href="admin.php?mode=deletealbum&a=' .$list[$i]['album_id']. '">Delete</a> ]';
					}

				
					$gallery_html[] = '<a href=portfolio.php?albums='.$list[$i]['album_id'].'><img src="folder.gif" class="directory"><br />' .addslashes($list[$i]['album_name']). '</a><br />' .$delete_link. '</li>';
					break;

				case "PHOTOS" :

					// construct photo name
					$name = $list[$i]['photo_proper'];

					// construct location
					$location = "photos/";

					// create thumbnail
					if (!file_exists($location. "/thumbs/" .$name))
					{
						thumbnail($name, $location. "/" .$name, $location. "/thumbs/");
					}

					// construct date
					$date = '<div class="date">' .date("d/m G:ia", $list[$i]['photo_date']). '</div>';

					// create the delete link
					$delete_link = '';
					if ($_SESSION['logged_in'])
					{
						$delete_link = '[ <a href="admin.php?mode=deletephoto&p=' .$list[$i]['photo_id']. '">Delete</a> ]';
					}

					// image information
					list($width, $height) = getimagesize($location . $list[$i]['photo_proper']);

					// add to the html
					$gallery_html[] = '<li><a href="' .$location . $list[$i]['photo_proper']. '" rel="lightbox[racing]" title="Photos"><img src="' .$location. "/thumbs/" .$name. '" class="picture"><br />View</a><br />' .$delete_link. '</li>';
					break;

				case "RAW" :

					$gallery_html[] = '<li><img src="' .$list[$i]. '" class="picture"></li>';
					break;
			}

			// shall we close the list
			if ( ($i + 1) % $row === 0 || ($i + 1) == $size)
			{
				$gallery_html[] = '</ul>';
			}
		}

		$gallery_html[] = '</div>';
	}

	return implode('', $gallery_html);
}
?>

so if i tried like this

function upload_files ($save_dir = '', $album=  .$value['album_id']. )

is this any way of calling the parameter like u said?? if not where can i find that heres the whole script could u just have a quick zip into it
once again the problem is that it only makes a copy of the image into the thumbnails folder if u chose from the drop down menu option main directory

<?php
/**
* create a sub album directory for photos
* to be stored in
*/
function create_album ($album_name, $sub_album = 0)
{
	global $db;

	$sql = "INSERT INTO " .ALBUMS_TABLE. "
		(
			album_name,
			sub_album
		)
		VALUES
		(
			'" .addslashes($album_name). "',
			" .intval($sub_album). "
		)";

	if ($db->query($sql))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/**
* get a list of sub albums
*/
function get_albums ($sub_album = 0)
{
	global $db;

	$sql = "SELECT *
		FROM " .ALBUMS_TABLE. "
		WHERE sub_album = " .intval($sub_album);

	$db->query($sql);

	// initialise album storage
	$albums = array();
	while ($row = $db->fetch())
	{
		$albums[] = $row;
	}

	return $albums;
}

/**
* get a list of photos within an album
*/
function get_photos ($album = 0)
{
	global $db;

	$sql = "SELECT *
		FROM " .PHOTOS_TABLE. "
		WHERE album_id = " .intval($album). "
		ORDER BY photo_id ASC";

	$db->query($sql);

	// initialise album storage
	$photos = array();
	while ($row = $db->fetch())
	{
		$photos[] = $row;
	}

	return $photos;
}

/**
* get a large version of a particular photo
*/
function get_large ($photo, $album = 0, $next = '')
{
	global $db, $template, $account_details;

	// shall we get the next / previous photo
	switch ($next)
	{
		case "next" :

			$next_sql = "AND photo_id > " .intval($photo). " ORDER BY photo_id ASC";
			break;

		case "previous" :

			$next_sql = "AND photo_id < " .intval($photo). " ORDER BY photo_id DESC";
			break;

		default :

			$next_sql = "AND photo_id = " .intval($photo);
			break;
	}

	$sql = "SELECT *
		FROM " .PHOTOS_TABLE. "
		WHERE album_id = " .intval($album). "
		" .$next_sql. "
		LIMIT 1";

	$db->query($sql);
	if ($db->num_rows() == 0)
	{
		return '';
	}
	else
	{
		$photo_info = $db->fetch();

		// note the total directory
		$location = 'photos/' .$photo_info['photo_proper'];

		// now we need to resize
		list($width, $height) = getimagesize($location);
		if ($width < 300)
		{
			$new_width = $width;
			$new_height = $height;
		}
		elseif ($width > $height)
		{
			$new_width = 300;
			$new_height = $height * ($new_width / $width);
		}
		elseif ($width < $height)
		{
			$new_width = $width * ($new_height / $height);
			$new_height = 300;
		}

		// work out the next link
		$next = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=next">Next</a>';
		$previous = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=previous">Previous</a>';			

		return '<div id="largephoto"><img src="' .$location. '" height="' .$new_height. '" width="' .$new_width. '" class="large"><br /><div id="prevnext">' .$previous. ' :: ' .$next. '</div></div>';
	}
}

/**
* get an array of locations
*/
function get_locations ()
{
	global $db;

	// initialise array
	$locations = array();

	// select albums
	$sql = "SELECT

			album_id,
			album_name

		FROM " .ALBUMS_TABLE;

	$db->query($sql);
	while ($row = $db->fetch())
	{
		$locations[] = $row;
		
	}

	return $locations;
}

/**
* make the locations table
*/
function make_locations ($locs)
{
	$html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>';
	foreach ($locs AS $key => $value)
	{
	     echo 'key = '.$key.' value = '.$value.'<br />'; 
		$html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>';
	}
	$html .= '</select>';

	return $html;
}

/**
* delete an album from the database
* does not delete the photos in it
*/
function delete_albums ($album_ids)
{
	global $db;

	if (sizeof($album_ids) > 0)
	{
		$sql = "DELETE FROM " .ALBUMS_TABLE. "
			WHERE album_id IN (" .implode(',', $album_ids). ")";
	
		if ($db->query($sql))
		{
			return TRUE;
		}
	}

	return FALSE;
}

/**
* delete a set of photos
*/
function delete_photos ($photo_ids)
{
	global $db;

	if (sizeof($photo_ids) > 0)
	{
		// select photo names for deletion
		$sql = "SELECT photo_proper
			FROM " .PHOTOS_TABLE. "
			WHERE photo_id IN (" .implode(',', $photo_ids). ")";

		$db->query($sql);

		$unlink_ids = array();
		while ($row = $db->fetch())
		{
			$unlink_ids[] = $row['photo_proper'];
		}

		// now delete the photos
		if (sizeof($unlink_ids) > 0)
		{
			$sql = "DELETE FROM " .PHOTOS_TABLE. "
				WHERE photo_id IN (" .implode(',', $photo_ids). ")";
	
			if ($db->query($sql))
			{
				// remove photo from directory
				for ($i = 0; $i < sizeof($unlink_ids); $i++)
				{
					unlink("photos/" .$unlink_ids[$i]);
					unlink("photos/thumbs/" .$unlink_ids[$i]);
				}
				return TRUE;
			}
		}
	}

	return FALSE;
}

/**
* upload a set of files
*/
function upload_files ($save_dir = '', $album = 0)
{
	global $db;

	// check the save dir is writable
	if (!is_writable($save_dir))
	{
		return FALSE;
	}

	// specify allowed file types
	$allowed_types = array (
	
		'image/jpg',
		'image/jpeg',
		'image/pjpeg',
		'image/gif'
	
	);

	// keep a list of uploaded files
	$uploaded = array();

	// store bytes uploaded
	$total_bytes = 0;

	// go through the list of files
	while (list($key, $value) = each($_FILES['userfile']['name']))
	{
		// check file has been passed
		if (!empty($value))
		{
			// find extension
			$extension = substr($_FILES['userfile']['name'][$key], strpos($_FILES['userfile']['name'][$key],".") + 1);

			// time + $key for name
			$name = time(). "_" .$key. "." .$extension;

			// save url
			$add = $save_dir. "/" .$name;

			if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $add))
			{
				chmod($add, 0777);

				// add photo to database
				create_photo($_FILES['userfile']['name'][$key], $name, $album);
			}
		}
	}

	return TRUE;
}

/**
* insert photo details into the database
*/
function create_photo ($photo_name, $key_name, $album = 0)
{
	global $db;

	// get the filesize
	if (!$size = filesize("photos/" .$key_name))
	{
		$size = 0;
	}

	// insert the photo in the database
	$sql = "INSERT INTO " .PHOTOS_TABLE. "
		(
			photo_name,
			photo_date,
			photo_proper,
			photo_size,
			album_id
		)
		VALUES
		(
			'" .addslashes($photo_name). "',
			" .time(). ",
			'" .addslashes($key_name). "',
			" .intval($size). ",
			" .$album. "
		)";

	if ($db->query($sql))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

/**
* get a complete raw copy of the directory
*/
function get_dir_contents ($dir)
{
	// declare content array
	$contents = array();

	// check gallery exists
	if (is_dir($dir))
	{
		if ($handle = opendir($dir))
		{
			while (FALSE !== ($file = readdir($handle)))
			{
				if ($file != '.' && $file != '..' && $file != 'thumbs')
				{
					if (file_exists($dir. '/thumbs/' .$file) || thumbnail($file, $dir. '/' .$file, $dir. '/thumbs'))
					{
						$contents[] = $dir. '/thumbs/' .$file;
					}
					else
					{
						$contents[] = 'no_image.gif';
					}
				}
			}
		}
	}

	return $contents;
}

/**
* create a thumbnail of a photo and store it
* in the thumbs directory
*/
function thumbnail ($filename, $source_file, $destination, $new_h = 75, $new_w = 75)
{
	if (!is_file($source_file))
	{
		return FALSE;
	}

	// get the image details
	list($old_w, $old_h, $type) = getimagesize($source_file);

	// create source image
	switch($type)
	{
		case 1:

			$source = @imagecreatefromgif($source_file);
			break;

		case 2:

			$source = @imagecreatefromjpeg($source_file);
			break;

		case 3:

			$source = @imagecreatefrompng($source_file);
			break;

		default :

			return FALSE;
	}

	// work out dimensions
	if ($old_w < $old_h)
	{
		$thumb_w = $new_w;
		$thumb_h = $old_h * ($new_h / $old_w);
	}
	elseif ($old_w > $old_h)
	{
		$thumb_w = $old_w * ($new_w / $old_h);
		$thumb_h = $new_h;
	}
	elseif ($old_w == $old_h)
	{
		$thumb_w = $new_w;
		$thumb_h = $new_h;
	}
	$thumb = @imagecreatetruecolor($thumb_w, $thumb_h);

	// create image
	imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h);

	// check we have a proper destination
	if (!is_dir($destination))
	{
		mkdir($destination, 0777);
	}

	// save image
	switch ($type)
	{
		case 1:
		case 2:

			imagejpeg($thumb, $destination. '/' .$filename);
			break;

		case 3:

			imagepng($thumb, $destination. '/' .$filename);
			break;
	}

	// memory saving
	imagedestroy($thumb);
	imagedestroy($source);

	// thumbnail created successfully
	return TRUE;
}

/**
* make the table to show the directories and photos
*/
function make_table ($list, $type, $row = 3)
{
	// initialize gallery html array
	$gallery_html = array();

	// check if we have a list > 0
	if ($size = sizeof($list))
	{
		switch ($type)
		{
			case "GALLERIES" :

				$gallery_html[] = '<div id="galleries">';
				break;

			case "PHOTOS" :
			case "RAW" :

				$gallery_html[] = '<div id="photos">';
				break;
		}

		// loop through list
		for ($i = 0; $i < sizeof($list); $i++)
		{
			// shall we open a new list
			if ($i &#37; $row == 0)
			{
				$gallery_html[] = '<ul>';
			}

			// add to list
			switch ($type)
			{
				case "GALLERIES" :

					// create the delete link
					$delete_link = '';
					if ($_SESSION['logged_in'])
					{
						$delete_link = '[ <a href="admin.php?mode=deletealbum&a=' .$list[$i]['album_id']. '">Delete</a> ]';
					}

				
					$gallery_html[] = '<a href=portfolio.php?albums='.$list[$i]['album_id'].'><img src="folder.gif" class="directory"><br />' .addslashes($list[$i]['album_name']). '</a><br />' .$delete_link. '</li>';
					break;

				case "PHOTOS" :

					// construct photo name
					$name = $list[$i]['photo_proper'];

					// construct location
					$location = "photos/";

					// create thumbnail
					if (!file_exists($location. "/thumbs/" .$name))
					{
						thumbnail($name, $location. "/" .$name, $location. "/thumbs/");
					}

					// construct date
					$date = '<div class="date">' .date("d/m G:ia", $list[$i]['photo_date']). '</div>';

					// create the delete link
					$delete_link = '';
					if ($_SESSION['logged_in'])
					{
						$delete_link = '[ <a href="admin.php?mode=deletephoto&p=' .$list[$i]['photo_id']. '">Delete</a> ]';
					}

					// image information
					list($width, $height) = getimagesize($location . $list[$i]['photo_proper']);

					// add to the html
					$gallery_html[] = '<li><a href="' .$location . $list[$i]['photo_proper']. '" rel="lightbox[racing]" title="Photos"><img src="' .$location. "/thumbs/" .$name. '" class="picture"><br />View</a><br />' .$delete_link. '</li>';
					break;

				case "RAW" :

					$gallery_html[] = '<li><img src="' .$list[$i]. '" class="picture"></li>';
					break;
			}

			// shall we close the list
			if ( ($i + 1) % $row === 0 || ($i + 1) == $size)
			{
				$gallery_html[] = '</ul>';
			}
		}

		$gallery_html[] = '</div>';
	}

	return implode('', $gallery_html);
}
?>

when i put that that here

function make_locations ($locs)
{
	$html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>';
	foreach ($locs AS $key => $value)
	{
	     echo 'key = '.$key.' value = '.$value.'<br />'; 
		$html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>';
	}
	$html .= '</select>';

	return $html;
}

it shows
key = 0 value = Array
key = 1 value = Array

the values are 1 and 0

this how the whole script is

the drop down menu

function make_locations ($locs)
{
	$html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>';
	foreach ($locs AS $key => $value)
	{
		$html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>';
	}
	$html .= '</select>';

	return $html;
}

the other part

function upload_files ($save_dir = '', $album = 0)
{
	global $db;

	// check the save dir is writable
	if (!is_writable($save_dir))
	{
		return FALSE;
	}

	// specify allowed file types
	$allowed_types = array (
	
		'image/jpg',
		'image/jpeg',
		'image/pjpeg',
		'image/gif'
	
	);

	// keep a list of uploaded files
	$uploaded = array();

	// store bytes uploaded
	$total_bytes = 0;

	// go through the list of files
	while (list($key, $value) = each($_FILES['userfile']['name']))
	{
		// check file has been passed
		if (!empty($value))
		{
			// find extension
			$extension = substr($_FILES['userfile']['name'][$key], strpos($_FILES['userfile']['name'][$key],".") + 1);

			// time + $key for name
			$name = time(). "_" .$key. "." .$extension;

			// save url
			$add = $save_dir. "/" .$name;

			if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $add))
			{
				chmod($add, 0777);

				// add photo to database
				create_photo($_FILES['userfile']['name'][$key], $name, $album);
			}
		}
	}

	return TRUE;
}

now i realised that on the drop dwon menu the firts option has the value of 0 and that on the other part of script where it says $album = 0 works together

but on the drop down menu the second option depends on mysql query this line
<option value=“’ .$value[‘album_id’]. '”>

but the with that the second part where says $album = 0 doesnt work if u chose the second option of the drop down menu because the value is not 0 how can i get so that it works depending on the second option has the second option is
<option value=“’ .$value[‘album_id’]. '”>

What?

It’s not exactly clear to me what you are trying to do but it appears to me that in

 
function make_locations ($locs) 
{ 
$html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>'; 
foreach ($locs AS $key => $value) 
{ 
$html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>'; 
} 
$html .= '</select>'; 
 
return $html; 
} 

you are passing an associative array to the function instead of a result set from a database query.

For debuging purposes try

 
foreach ($locs AS $key => $value) 
    { 
     echo 'key = '.$key.' value = '.$value.'<br />'; 
}
die();

to see what the values in your array actually are.

what would these file or the sintax that calls these function look like i’ve been learning php bt never really gt into these function sorry if i’m sounding too dumb
do u have any example cz some1 done my website but as i been learning php i’ve been able to change alot things into it but now gt stuck with these functions things what would a sintax that calls a function look like and would that be on the main page that has the buttom upload or something?? :shifty:

anyone???

No. A call to the function upload_files would look something like


$result = upload_files($dir, $value['album_id']);

heres the whole script

I’m sorry, but this is not the whole script. This is a collection of functions. Probably, this file is included in other pages, that call these functions.

anyone found what am i doing wrong???

i think is this one

<?php
define('ROOT_DIR', './');
define('THIS_SCRIPT', 'admin');
define('PROPER', TRUE);

/**
* include common files
*/
include_once(ROOT_DIR. 'includes/common.inc.php');
include_once(ROOT_DIR. 'includes/functions_gallery.inc.php');

/**
* check user is logged in
*/
if (!$_SESSION['logged_in'])
{
	header("location:" .ROOT_DIR. "login.php");
	exit();
}

/**
* can we perform
*/
$can_perform = FALSE;
switch ($mode)
{
	case "upload" :

		if (isset($_FILES['userfile']) && isset($_POST['locations']))
		{
			$can_perform = TRUE;
		}
		break;

	case "createalbum" :
	
		if (isset($_POST['album_name']) && !empty($_POST['album_name']) && isset($_POST['locations']))
		{
			$can_perform = TRUE;
		}
		break;

	case "deletealbum" :

		$album_ids = array();
		if (isset($_GET['a']))
		{
			$album_ids[] = $_GET['a'];
		}

		$can_perform = TRUE;
		break;

	case "move" :
	case "deletephoto" :
	
		$photo_ids = array();
		if (isset($_GET['p']))
		{
			$photo_ids[] = intval($_GET['p']);
		}

		$can_perform = TRUE;
		break;
}

/**
* perform actions
*/
if ($can_perform)
{
	switch ($mode)
	{
		case "upload" :
		
			if (upload_files("photos", $_POST['locations']))
			{
				$errors->raise_error(000, "Your files have been uploaded successfully!");
			}
			break;

		case "createalbum" :
		
			if (create_album($_POST['album_name'], $_POST['locations']))
			{
			}
			break;

		case "deletealbum" :
		
			if (delete_albums($album_ids))
			{
			}
			break;

		case "move" :
		
			if (move_photo($photo_ids))
			{
			}
			break;

		case "deletephoto" :
		
			if (delete_photos($photo_ids))
			{
			}
			break;
	}
}

/**
* get data we need
*/
switch ($mode)
{
	case "upload" :
	case "createalbum" :
	case "deletealbum" :

		$locs = get_locations();
		$template->assign_vars(array(

			'LOCATIONS' => make_locations($locs))

		);
		break;
}

/**
* what file do we need
*/
switch ($mode)
{
	case "createalbum" :

		$admin_file = 'albums';
		break;

	case "upload" :

		$admin_file = 'upload';
		break;

	default :

		$admin_file = 'admin';
		break;
}

/**
* parse the file
*/
include(ROOT_DIR. "style/header.php");

$template->parse($admin_file);

include(ROOT_DIR. "style/footer.php");
?>

This

function upload_files ($save_dir = '', [COLOR="Red"]$album = 0[/COLOR])

doesn’t mean that the value of $album has to be 0, or that the code will only work when $album is 0. It means that when you call this function in your code, and you do not pass a value for the second parameter, by default its value will be 0.

So for it to work with a value different from zero you have to call the function with the correct parameters. In the code you posted, though, I don’t see such a call, so I can’t tell if you’re doing everything ok or not.

It was late last night (for me at least), and we’re not always here, so please be patient :slight_smile:

In this code, I see this call to the upload_files function:


if (upload_files("photos", $_POST['locations']))

What you could do, to see if the values passed on to the function are the ones you want, is echo the value of $_POST[‘locations’] before the if.