Hi im having abit of trouble adapting a tutorial i found on nettuts for creating a photography website heres the link if you wanna check it out:


Anyways this code is fine, although because i have several categories of photos i need to store them in seperate tables, was wondering if i could use a drop down box to let the user choose the table where they want the photos to go. Any help is greatly appreciated.

ive posted the code below for the admin page. i included the select box i just dont have a clue on the php side of things thanks again.


require 'config.php';
require 'functions.php';
require 'common.php';

if(isset($_FILES['fupload'])) {

    $filename = addslashes($_FILES['fupload']['name']); //get image user inputs
    $source = $_FILES['fupload']['tmp_name'];    // temp directory where image is stored
    $target = $path_to_image_directory . $filename;
    $description = addslashes($_POST['description']);    
    $src = $path_to_image_directory . $filename;
    $tn_src = $path_to_thumbs_directory  . $filename;    
    // Validates the form input
    if(strlen($_POST['description']) < 5) // validates user inputted something larger than 5 characters long
    $error['description'] = '<p class="alert">Please enter a description for the photo. </p>';
    if($filename == '' || !preg_match('/[.](jpg)|(gif)|(png)|(jpeg)$/', $filename)) // check user chose a picture to upload
    $error['no_file'] = '<p class="alert">Please select an image to upload </p>';
    if(!$error) {
        move_uploaded_file($source, $target);    // move image from temporary directory 
        $q = "INSERT into photo(description, src, tn_src) VALUES('$description', '$src', '$tn_src')"; //update database
        $result = $mysqli->query($q) or die(mysqli_error($mysqli));
        if($result) {
            echo "Your Photograph has been uploaded";
    }  // end preg_match

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" href="css/default.css" />
	<title>My Photos</title>

    <h1>My Photos</h1>
    <ul><?php getPhotos(); ?></ul>

    <h1>Upload a Photo</h1>

    <form enctype="multipart/form-data" method="post" action="admin.php">
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
	    <p><input type="file" name="fupload" /></p>
	    <p><label for="description">Enter a Description: </label>
	    <textarea rows="6" cols="50" id="description" name="description"></textarea></p>
        <p>    <select name="catagory">
     			 <option value="sports">Sports</option>
      		     <option value="london">London</option>
     			 <option value="macro">Macro</option>
     			 <option value="landscapes">Landscapes</option>
     			 <option value="local">Local</option>
	    <p><input type="submit" value="Upload Photo" name="submit" /></p>

    if ($error['no_file']) echo $error['no_file'];
	if ($error['no_catagory']) echo $error['no_catagory'];
    if ($error['description']) echo $error['description'];

    <br />
    <a href="deletephoto.php">Delete A Photo</a>


hi this is nathen i think this is usefull some what for you,

			if(move_uploaded_file($_FILES['userfile']['tmp_name'],$realpath )) 
			/************************************Resizing the image 75x75****************/
		$bgim_file_name = $path."/".$filename; 
		$bgimage_attribs = getimagesize($bgim_file_name);
			$bgim_old = imagecreatefromgif($bgim_file_name); 
			 $bgim_old = imagecreatefromjpeg($bgim_file_name);
		$bgth_max_width = 75; //for Album image
		$bgth_max_height = 75;
		$bgratio = ($bgwidth > $bgheight) ? $bgth_max_width/$bgimage_attribs[0] : $bgth_max_height/$bgimage_attribs[1];
		$bgth_width = 75;//$image_attribs[0] * $ratio; 
		$bgth_height = 75;//$image_attribs[1] * $ratio;
		$bgim_new = imagecreatetruecolor($bgth_width,$bgth_height); 
		$bgth_file_name = "uploads/deals/thumbnails/$filename";
		imagecopyresampled($bgim_new,$bgim_old,0,0,0,0,$bgth_width,$bgth_height, $bgimage_attribs[0], $bgimage_attribs[1]);