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:

http://net.tutsplus.com/videos/screencasts/building-the-back-end-of-a-photo-site/

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.

<?php

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";
        }
        
        createThumbnail($filename);
        
    }  // end preg_match
}     

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

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

<body>
    <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>
   			    </select>
	    
	    <p><input type="submit" value="Upload Photo" name="submit" /></p>
    </form>

    <?php
    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>

</body>
</html>

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

$uploaddir="uploads/deals/";
		$filetype1=$_FILES[userfile][type];
		$filename=$_FILES[userfile][name];
		$realpath=$uploaddir.$filename;
		if(!empty($filetype1)) 
		{	
		
			if(move_uploaded_file($_FILES['userfile']['tmp_name'],$realpath )) 
			{
			
			}
			
			/************************************Resizing the image 75x75****************/
		$path="uploads/deals";
		$bgim_file_name = $path."/".$filename; 
		$bgimage_attribs = getimagesize($bgim_file_name);
	
		if($filetype1=='image/gif')	
				{
			$bgim_old = imagecreatefromgif($bgim_file_name); 
				}	
		else	
				{
			 $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); 
		imageantialias($bgim_new,true); 
		$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]);
	
		if($filetype1=='image/gif')	
				{									
				imagegif($bgim_new,$bgth_file_name,100); 
				}	
		else	
				{
			imagejpeg($bgim_new,$bgth_file_name,100);
				}
				
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.