Jump to content

upload multiple images...from the top


Andorphin

Recommended Posts

Hi All

 

Been desperate to crack this nut for a few years now, but seem to be failing epically!

 

I have been building a property/real estate web site for a long time, but I have no training and have been learning as I go. I have a script written that allows me to upload data and store it in my database, what I was looking to do was add a section that allows me to upload multiple images at the same time, and store the location to another table in the same database.

 

So what I was looking to do was remove all the...lets say rubbish to be nice...and see where it takes us.

 

I apologize in advance for the lack of santized code...I am coding locally only, in an admin area, and will rectify before launching the site...just trying to get the bones of the script in place.

 

Ok, first we have my form as shown here, warts and all.

<?php
/**
* Create Listing
*/

?>

<div id="admin" class="intern">
    <div class="banner">
      <div class="logbanner">CREATE LISTING</div>
    </div>
<div class="padding">
<form action="adminprocess.php" method="POST" enctype="multipart/form-data">
	<table border="0" cellpadding="2" cellspacing="2" width="700">
		<tr>
			<td align="right"><label class="text">Property Title: </label></td>
			<td><input type="text" name="property_title" maxlength="50" value="" size="50"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">Selling Agent: </label></td>
			<td><input type="text" name="agent" maxlength="30" value="<?php echo $session->username; ?>"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">Style: </label></td>
			<td>
				<select id="property_type" name="property_type">
					<option value="Not Selected" selected>Not Selected</option>
					<option value="Detached">Detached</option>
					<option value="Semi-Deatched">Semi-Detached</option>
					<option value="End Terrace">End Terrace</option>
					<option value="Mid Terrace">Mid Terrace</option>
					<option value="Flat">Flat</option>
					<option value="Ground Floor Flat">Ground Floor Flat</option>
					<option value="4 in a Block">4 in a Block</option>
					<option value="Bungalow">Bungalow</option>
					<option value="Apartment">Apartment</option>
					<option value="Studio">Studio</option>
					<option value="Maisonette">Maisonette</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Address: </label></td>
			<td><input type="text" name="address_one" maxlength="30" value="" size="50"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">Address: </label></td>
			<td><input type="text" name="address_two" maxlength="30" value="" size="50"></td>
		</tr>
		<tr>
			<td align="right"><label  class="text">Town: </label></td>
			<td><input type="text" name="town" maxlength="30" value="" size="50"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">County: </label></td>
			<td>
				<select id="county" name="county">
					<option value="Fife" selected>Fife</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Post Code: </label></td>
			<td><input type="text" name="postcode" maxlength="30" value="" size="15"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">Price: </label></td>
			<td>
				<select id="price_cond" name="price_cond">
					<option value="Not Selected" selected>Not Selected</option>
					<option value="Offers Over">Offers Over</option>
					<option value="Fixed Price">Fixed Price</option>
				</select>
					<input type="text" name="price" maxlength="30" value="" size="32">
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Property Status: </label></td>
			<td>
				<select id="status" name="status">
					<option value="Not Selected" selected>Not Selected</option>
					<option value="Offers Over">For Sale</option>
					<option value="Fixed Price">Sold Subject to Signed Missives</option>
					<option value="Fixed Price">Sold Subject to Survey</option>
					<option value="Fixed Price">Price Reduced</option>
					<option value="Fixed Price">Sold</option>
					<option value="Fixed Price">Re-Listed</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Description Header: </label></td>
			<td><input type="text" name="deschead" maxlength="30" value="" size="50"></td>
		</tr>
		<tr>
			<td align="right"><label class="text">Description: </label></td>
			<td><textarea cols="40" rows="8" type="text" name="desc" maxlength="1000" value=""></textarea></td>
		</tr>





<!-- I want the images to be added here -->





		<tr>
			<td align="right"><label class="text">Reception Rooms: </label></td>
			<td>
				<select id="recrooms" name="recrooms">
					<option value="0" selected>Not Selected</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7+</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Bedrooms: </label></td>
			<td>
				<select id="bedrooms" name="bedrooms">
					<option value="0" selected>Not Selected</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7+</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Bathrooms: </label></td>
			<td>
				<select id="bathrooms" name="bathrooms">
					<option value="0" selected>Not Selected</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
					<option value="4">4</option>
					<option value="5">5</option>
					<option value="6">6</option>
					<option value="7">7+</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Garden: </label></td>
			<td>
				<select id="garden" name="garden">
					<option value="Not Selected" selected>Not Selected</option>
					<option value="Yes">Yes</option>
					<option value="No">No</option>
					<option value="Shared">Shared</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Garage: </label></td>
			<td>
				<select id="garage" name="garage">
					<option value="Not Selected" selected>Not Selected</option>
					<option value="Yes">Yes</option>
					<option value="No">No</option>
					<option value="Shared">Shared</option>
				</select>
			</td>
		</tr>
		<tr>
			<td align="right"><label class="text">Additional Info: <br />** Not seen by site users **</label></td>
			<td><textarea cols="40" rows="8" type="text" name="addinfo" maxlength="1000" value=""></textarea></td>
		</tr>
		<tr>
			<td align="right"><label class="text"> </label></td>
			<td>
				<input type="hidden" name="subcreatelisting" value="1">
				<input type="submit" value="Create Listing">
			</td>
		</tr>
	</table>
</form> 
<?php echo $form->error("creListing"); ?>
</div>
</div>

 

next I have my process page which has the following function included...

  function procCreateListing(){

      global $session, $database, $form;
         $q = "INSERT INTO ".TBL_PROP."(prop_id, prop_agent, prop_type, prop_add_1, prop_add_2, prop_town, prop_county, prop_pc, prop_price, prop_price_cond, prop_rec_rooms, prop_bedrooms, prop_bathrooms, prop_status, prop_garden, prop_garage, prop_description_header, prop_description, prop_add_info, prop_add_date) VALUES ('".$_POST['property_title']."', '".$_POST['agent']."', '".$_POST['property_type']."', '".$_POST['address_one']."', '".$_POST['address_two']."', '".$_POST['town']."', '".$_POST['county']."', '".$_POST['postcode']."', '".$_POST['price']."', '".$_POST['price_cond']."', '".$_POST['recrooms']."', '".$_POST['bedrooms']."', '".$_POST['bathrooms']."', '".$_POST['status']."', '".$_POST['garden']."', '".$_POST['garage']."', '".$_POST['deschead']."', '".$_POST['desc']."', '".$_POST['addinfo']."', '".$_POST['date']."')";
         $database->query($q);


   }

 

and I have 2 tables in mysql

 

prop_listing and imagebin

CREATE TABLE `kea_userclass`.`prop_listing` (
`prop_id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`prop_agent` VARCHAR( 40 ) NOT NULL ,
`prop_type` VARCHAR( 20 ) NOT NULL ,
`prop_add_1` VARCHAR( 50 ) NOT NULL ,
`prop_add_2` VARCHAR( 50 ) NOT NULL ,
`prop_town` VARCHAR( 30 ) NOT NULL ,
`prop_county` VARCHAR( 25 ) NOT NULL ,
`prop_pc` VARCHAR( 8 ) NOT NULL ,
`prop_price` INT( 10 ) NOT NULL ,
`prop_price_cond` VARCHAR( 20 ) NOT NULL ,
`prop_rec_rooms` INT( 2 ) NOT NULL ,
`prop_bedrooms` INT( 3 ) NOT NULL ,
`prop_bathrooms` INT( 2 ) NOT NULL ,
`prop_status` VARCHAR( 20 ) NOT NULL ,
`prop_garage` INT( 1 ) NOT NULL ,
`prop_garden` INT( 1 ) NOT NULL ,
`prop_description_header` VARCHAR( 50 ) NOT NULL ,
`prop_description` VARCHAR( 2000 ) NOT NULL ,
`prop_add_info` VARCHAR( 2000 ) NOT NULL ,
`prop_add_date` DATE NOT NULL ,
PRIMARY KEY ( `prop_id` ) 
) ENGINE = MYISAM ;

CREATE TABLE `imagebin` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`item_id` int( 11 ) NOT NULL ,
`image` varchar( 255 ) NOT NULL ,
PRIMARY KEY ( `id` ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1;

 

first of all thanks for getting this far, I know it is a lot of reading, and a lot to ask for, but now I am stuck...

[*]I need a section on my form that would allow me to upload 8 images, and store them in a directory folder

[*]I need the location saved into my imagebin table

[*]thats it just now

 

Many thanks for reading, and I hope someone can take me under their wing and help me passed this hurdle

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.