Jump to content

barbs75

Members
  • Posts

    97
  • Joined

  • Last visited

    Never

Everything posted by barbs75

  1. Hey guys, Just wandering if any of you guys know where i would be able to find a good script to allow me to fade in/out through a series of images? cheers Craig
  2. Hey Mike, Firstly thankyou for really helping me out here! I get what you are doing with naming the inputfields with 'userfile[$image_id]' as then i can use the key of each array element to look up the image from the database where i can find the filename etc... The only issue i am having is with iterating through the inputfiles..... The steps which i think need to be taken are: for each of the userfile array elements: take the key of the element and retrieve the filename of the image also take the image name of the image check the directory for the filename, and if it exists delete it do same for thumbnail then, continue with normal upload and update database. Is that right?!? i didnt really understand what was happening with the php you wrote on your last post? bit confused with that.... I am having problems iterating through each of the userfile post data tried using a foreach loop as follows: foreach($_POST['userfile'] as $key => $value){ echo 'the value of the array usefile is'.$value; } but i get PARSE ERRORS, it is obviously a two-dimensional array, so how do i loop through these post items?? cheers again Craig
  3. Hey Mike, Yeah, what you have suggested would work, but i want the user to be able to upload multiple images at a time, and i want the image to be deleted and replaced to be determined by the user choosing it?? which i wanted to do somehow with which inputfield the user selects an image on, determines which image is being replaced.. here is the php/html of the upload part: <?php if ($function =='edit'){ ?> <table width="100%"> <tr> <td colspan="3"><p class="largeblack">Below are thumbnail versions of the images you successfully uploaded to our server for your property image gallery:</p></td> </tr> <tr> <?php $sql = "SELECT * FROM images WHERE house_id = '$house_id'"; $query = mysql_query($sql); while($data = mysql_fetch_assoc($query)){ echo '<td align="center" width="33%"><img src="'.$data['thumbnail_filename'].'" alt="uploaded image" />'; echo '</td>'; } ?> </tr> </table> <FORM ENCTYPE="multipart/form-data" action="stage3_process.php5?do=<?php echo $function?>&id=<?php echo $house_id?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1100000" /> <input type='hidden' name='stage' value='<?php echo $stage + 1 ?>'/> <input type="image" src="Images/upload.png" align="right" name="Send File" /> <br /> <br /> </FORM> <?php }else{ ?> <FORM ENCTYPE="multipart/form-data" action="stage3_process.php5" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1100000" /> <div id="divinputfile"> <input class="open" name="userfile[]" type="file" size="60" id="userfile[]" /> <!--<div id="fakeinputfile"><input name="fakeuserfile" type="text" id="fakeuserfile" /></div>--> </div> <div id="divinputfile2"> <input name="userfile[]" type="file" size="60" id="userfile[]" /> <!--<div id="fakeinputfile2"><input name="fakeuserfile2" type="text" id="fakeuserfile2" /></div>--> </div> <div id="divinputfile3"> <input name="userfile[]" type="file" size="60" id="userfile[]" /> <!--<div id="fakeinputfile3"><input name="fakeuserfile3" type="text" id="fakeuserfile3" /></div>--> </div> <br /> <input type='hidden' name='stage' value='<?php echo $stage + 1 ?>'/> <input type="image" src="Images/upload.png" align="right" name="Send File" /> <br /> <br /> </FORM> <?php }?> Each of the upload fields when the user is not editing their property are stored in an array (userfile[]) these are then processed in a for loop. For the editing i thought i could try and store the filename of each of the uploaded images on display in an array, which could correspond to the new filename inputfield number when posting it..... so, the images that are already uploaded and displayed have the filenames: pic 1: barbs1.jpg -- image[0] pic 2: barbs2.jpg -- image[1] pic 3: barbs3.jpg -- image[2] then the inputfield id's for the inputfields displayed where the user can select an image to be replaced would look something like this: image 1 replace: <input class="open" name="userfile[]" type="file" size="60" id="userfile[]" /> image 2 replace: <input class="open" name="userfile[]" type="file" size="60" id="userfile[]" /> image 3 replace: <input class="open" name="userfile[]" type="file" size="60" id="userfile[]" /> so what i was thinking of doing was if the user changed the first two images, then userfile[0] would correspond to image[0] and then userfile[1] would correspond to image[1]. But if the user changes image 1 and image 3 then image 3 is going to retrieve the wrong filename..... thats why i thought i could use JS, as when the user clicks on the file upload window, the hidden field is generated, so then the image filename will only be posted for the images that are changed... god really confusing....do you think that would work? cheers Craig
  4. actually, thinkking about it, in my database i have the filenames stored and also have the house_id, username and user_id stored for each image. So i can refer to the filename by checking for images with the house_id (each house can only have 3 images) and username to pull the filenames..... then use the filenames to check the directories and delete the images.... d'oh!! but then it will remove all three, which i don't want because the user might only decide to change one of the images..... really stumped here ??? cheers Craig
  5. hey mikeschroeder, cheers for your help! what i do though is i re-name the uploaded image, using the users username and then retrieveing how many images they have uploaded by referring to 'num-uploads' field in my database which increments everytime the user uploads an image. The thumbs are doine the same way but have 'thumb_' infront of it, so i should have any problems with what you have suggested right? The only thing i'm having problem i'm having is detecting which image is being changed to grab the filename to delete it? i don't know if you would know how to do this? basically what i have at the moment, is the images that have been uploaded are displayed on screen, there is then a file upload file underneath where they select the image they want to replace it with and then the submit button for the form is clicked, and is processed on another php page. I need to somehow detect which image is being replaced and then use that filename to retrieve it, and delete it...i can't think how i can do that without using JS or AJAX?? I was thinking of having a hidden field containing the image filename when the form is submitted, but there would be no way of detecting which image is being replaced....bit confusing...but do you get me?? any ideas? Cheers Craig
  6. hey kiwidave, No, the 3 images are different, because i have a gallery for each property. The thumbnail is created based on the original using imagecopyresampled() and set to dimensions that i have set.. cheers, i think i know how i am going to do it now....i think cheers Craig
  7. Hey budimir, The user when they upload a property, upload 3 images of their property. These are saved in a local directory and then the filename of the image and the created thumbnail are stored in a database table. What i want to be able to do is allow the user to change the images they have uploaded. So they can upload 3 new images which will then overwrite the originals that were stored. I have been doing some research, and i think the best way of doing this is having a function to delete the images that they are changing, and then just upload the new images as their 3 images...hence they will be replaced. I have seen the unlink() function which deletes the file right? so i need collect the filenames of the images that are being replaced, delete them, and then just do a normal upload with the 3 images they want to upload as their new ones..... does that make sense? is that the best way of going about it? cheers Craig
  8. Can anyone help me here? ot give me some advice? cheers Craig
  9. Hi Guys, I have a script which uploads images fine, and creates thumbnails easily too. The only thing i am not sure of doing is overwriting these images. What i want to do is, once a user has uploaded images, they are stored in a directory: 'Images/image1.jpg' like that, and the filename is then stored in my database to refer to. But i want the user to be able to new images if they wish, which will overwrite the original images that they have? So overwriting the image that is already there with the new one, and if i can keep the filenames the same so that i don't have to change the data in the database!! Whats the best way of doing this?? Do i have to delete the original images and then just post up the new ones? (using unlink()??) or is there a simpler way of doing this? any help would be great! cheers Craig
  10. hey!! and guess what? i used your idea and it works prefectly!!! i have wasted SO much time, god i feel rather annoyed! and relieved at the same time! cheers for your help!! Craig
  11. ok, I will show you my page of code which i am working on: <?php //turn on sessions session_start(); header("Cache-control: private"); //collect data of whether the user is uploading or editing $function = $_GET['do']; //Receive house_id from URL $house_id = $_GET['id']; //checking if user is logged in, if not send them to login screen if (!$_SESSION['username']) { include("function/login.php"); exit(); } //checking that the user has completed stage 1 $stage = (int) $_SESSION['stage']; if (!$stage == 2)//if they haven't { header("Location: house_upload.php");//send them back to stage 1 //NEED TO STORE AN ERROR MESSAGE HERE TO DISPLAY ON STAGE 1 INDICATING THE USER THAT THEY HAVEN'T COMPLETED STAGE 1 YET!! } $clickCount; if($function == 'edit'){ include('editProperty_fns.php'); require_once('database.php'); //mysql statement to read users data from database to retrieve details $query_house = mysql_query("SELECT * FROM house WHERE house_id = '$house_id'"); $query_bed = mysql_query("SELECT * FROM bedrooms WHERE house_id = '$house_id'"); $query_room = mysql_query("SELECT * FROM rooms WHERE house_id = '$house_id'"); $query_bath = mysql_query("SELECT * FROM bathrooms WHERE house_id = '$house_id'"); $house_info = mysql_fetch_array($query_house); $bedroom_info = mysql_fetch_array($query_bed); $room_info = mysql_fetch_array($query_room); $num_houses = mysql_num_rows($query_house); $num_bedrooms = mysql_num_rows($query_bed); $num_bathrooms = mysql_num_rows($query_bath); } include('function/login_status.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="Style1.css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="ie7.css" /> <![endif]--> <link rel="icon" href="Images/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="Images/favicon.ico" type="image/x-icon" /> <title>Property Manager - House details</title> <meta name="Description" content="Find your dream property online, Search for any property for sale in a range of areas in the UK with go4home" /> <meta name="Keywords" content="Find a property, find property, find property in UK, search for a property, Property up for sale, find property up for sale, Property market, Advertise your home to sell, go4home.co.uk, go4home" /> <script type="text/javascript"> /*<![CDATA[*/ function create_fields(nr,roomType){ var root=document.getElementById(roomType); var allB=[], allD=root.getElementsByTagName('div'), i=0, d; // set the collection of the elements with className=inputfield while(d=allD[i++]){ d.className=='inputfield'?allB[allB.length]=d:null; } //removes all the elements, except the first for(var j=allB.length-1;j>=1;j--){ allB[j].parentNode.removeChild(allB[j]); } if(nr==1){return}//stops if a single bedroom is selected var clone;//the clone var tags={'label':['for'],'input':['id','name'],'textarea':['id','name'],'p':[null]} var obj, o, m, a, c; for(var k=2;k<nr+1;k++){ clone=allB[0].cloneNode(true); for(p in tags){ obj=clone.getElementsByTagName(p);m=0; while(o=obj[m++]){ for(var q=0;q<tags[p].length;q++){ if(p=='p'&&o.className=='largeblack'){ c=o.getElementsByTagName('strong')[0].firstChild; c.nodeValue=c.nodeValue.replace(/_1/,'_'+k); } else if(p!='p'){ a=o.getAttribute(tags[p][q]); o.setAttribute(tags[p][q],a.replace(/1/,k)); } } } } root.appendChild(clone); } } // This function will autofill form fields values function autofill(width,height,description) { document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = width; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = length; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = description; } /*]]>*/ </script> <script type="text/javascript"> var count = 0; function generate_room(){ count += 1; var num = count; document.getElementById('rooms').appendChild(create_inputfield(num)); document.getElementById('deleteRoom').style.visibility = 'visible'; return count; } //function to create inputfield div and all xhtml content inside function create_inputfield(num){ //create xhtml for inputfield element declaration var inputfield = document.createElement('div'); var divClassName = 'inputfield';//set classname inputfield.className = divClassName;//add class and class name to inputfield var inputfieldContent = '<p class="largeblack"><strong>Added Room '+num+'</strong></p><label class="room" for="extraroom_name_'+num+'">Type:</label><select class="open" name="extraroom['+num+'][0]" id="extraroom['+num+'][0]"><option class="open">--Please Select--</option><option class="open" value="study">Study</option><option class="open" value="games">Games Room</option><option class="open" value="Reception">Reception</option><option class="open" value="conservatory">Conservatory</option></select><br /><br />';//variable containing xhtml content inputfield.innerHTML = inputfieldContent;//adds xhtml content to inputfield inputfield.appendChild(create_dimensiondiv(num));//adds on element created by function inputfield.appendChild(create_descriptionHolder(num));//adds on element created by function return inputfield;//return variable inputfield } //function to create dimensions div function create_dimensiondiv(num){ var dimensiondiv = document.createElement('div'); var divClassName = 'dimensions'; dimensiondiv.className = divClassName; dimensiondiv.innerHTML = '<label class="room" for="extraroom['+num+'][1]">Dimensions:<br/><span class="textSmallGreen">(in feet)</span></label><input class="open" name="extraroom['+num+'][1]" id="extraroom['+num+'][1]" type="text" size="5" value="" /> x <input class="open" name="extraroom['+num+'][2]" id="extraroom['+num+'][2]" type="text" size="5" value="" />'; return dimensiondiv; } //function to create descriptionHolder div function create_descriptionHolder(num){ var descriptionHolder = document.createElement('div'); var divClassName = 'descriptionHolder'; descriptionHolder.className = divClassName; descriptionHolder.innerHTML = '<label class="room" for="extraroom['+num+'][3]">Description:<br/><span class="textSmallGreen">(max. 100 words)</span></label><textarea class="open" name="extraroom['+num+'][3]" id="extraroom['+num+'][3]" size="100" cols="35" rows="5">Enter your description here.....</textarea>'; return descriptionHolder; } function remove_room(theClass) { var allPageTags = document.getElementById('rooms').getElementsByTagName("*"); for(var i=allPageTags.length-1;i>=0;i--){ if(allPageTags[i].className==theClass){ allPageTags[i].parentNode.removeChild(allPageTags[i]);break } } } </script> </head> <body> <div id="mainContainer"> <div id="container-Content"> <div id="content-TopContent"> <?php if(isset($_SESSION['username'])){ show_loginBar(); }else{ show_normalBar($current_page); } ?> <!--End of TopBar --> <div id="navigation-wrapper"> <ul id="nav"> <li class="home"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="index.php">Home of site</a></li> </ul> <li class="search"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="displayhouses.php">Properties for sale</a></li> <li class="nav"><a class="nav" href="">Search criteria</a></li> </ul> </li> <li class="moneyMarket"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Expert advice</a></li> <li class="nav"><a class="nav" href="">Home insurance</a></li> <li class="nav"><a class="nav" href="">What can you afford?</a></li> </ul> </li> <li class="goBuy"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Search properties</a></li> <li class="nav"><a class="nav" href="">Buyer's guide</a></li> </ul> </li> <li class="goSell"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="house_upload.php">List a property</a></li> <li class="nav"><a class="nav" href="">Seller's guide</a></li> </ul> </li> <li class="help"> <ul class="secondlevel"> <li class="nav"><a class="nav" href="">Contact us</a></li> <li class="nav"><a class="nav" href="">About go4home</a></li> <li class="nav"><a class="nav" href="">Frequently Asked Questions</a></li> <li class="nav"><a class="nav" href="">Technical guide</a></li> <li class="nav"><a class="nav" href="">Terms & Conditions</a></li> </ul> </li> </ul> </div><!--End of navigation-wrapper--> </div><!--End of content-Topcontent --> <div id="profileBar"> <div id="userInfoLarge"><h2 class="shadow" title="<?php echo $_SESSION['username'] ?>"><b><?php echo $_SESSION['username'] ?></b></h2></div> <div id="userInfoLogoLarge"><img src="Images/UserlogoLARGE.png" alt="User profile logo LARGE"/></div> <div id="profileTitle"><h2 class="shadow" title="Your Profile"><b>Your Profile</b></h2></div> </div><!--End of profileBar--> <div id="content-bodycontent"> <div id="Redcontentwindow"> <div class="Redwindowtop"> <div id="headerLogo"><img src="Images/PropertyManagerSMALL.png" alt="Property Manager"/></div> <span><h4>Property Manager</h4></span> </div> <div class="Redwindowbody"> <?php //Save any submitted data if ($stage > 1) { foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } } ?> <div id="submitCustomerForm"> <ul class="uploadProgress"> <li class="upload"><img src="Images/step1DONE.png" alt="Stage 1 - Your details"/></li> <li class="upload"><img src="Images/step2ACTIVE.png" alt="Stage 2 - House details"/></li> <li class="upload"><img src="Images/step3UNACTIVE.png" alt="Stage 3 - Image upload"/></li> <li class="upload"><img src="Images/step4UNACTIVE.png" alt="Property Manager complete"/></li> </ul> <hr /> <p class="largeblack"><strong>Step 2 - Your House Details</strong></p> <p class="largeblack"> Please fill in the room specifications and descriptions below </p> <?php if (isset($_SESSION['error_storage'])) { $strError = '<div class="formerror" style="width:100%;margin-left:0;"><p class="largeblue" style="margin:5px;"><strong><img src="/images/warningtriangle.png">Please check the following and try again:</strong></p><ul style="padding:0 5px 5px 20px;list-style:disc;">'; // Get each error and add it to the error string // as a list item. foreach ($_SESSION['error_storage'] as $error) { $strError .= "<li>$error</li>"; } $strError .= '</ul></div><br />'; echo $strError; } ?> <h7>Your House details</h7> <br /> <form action="stage2_process.php" method="post" name="upload_stage2"> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['propertyTypeEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="propertyType">Property type:</label> <select class="open" style="float:left;" name="propertyType2" id="propertyType2"> <option class="open" value="" <?php if($house_info['property_type2'] == ''){echo 'selected';}?>>--Please Select--</option> <option class="open" value="house" <?php if($house_info['property_type2'] == 'house'){echo 'selected';}?>>House</option> <option class="open" value="apartment" <?php if($house_info['property_type2'] == 'apartment'){echo 'selected';}?>>Apartment</option> <option class="open" value="Flat" <?php if($house_info['property_type2'] == 'Flat'){echo 'selected';}?>>Flat</option> </select> <select class="open" style="float:right;margin-right:170px;" name="propertyType" id="propertyType"> <option class="open" value="">--Please Select--</option> <option class="open" value="??">N/A</option> <option class="open" value="detached" <?php if($house_info['property_type'] == 'detached'){echo 'selected';}?>>Detached</option> <option class="open" value="semi-detached" <?php if($house_info['property_type'] == 'semi-detached'){echo 'selected';}?>>Semi-Detached</option> <option class="open" value="terraced" <?php if($house_info['property_type'] == 'terraced'){echo 'selected';}?>>Terraced</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['propertyTypeEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo '<img src="/images/warningtriangle.png" style="position:relative;left:155px;padding-top:3px;" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['propertyTypeEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['statusEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="status">Status:</label> <select class="open" name="status" id="status"> <option class="open" value="">--Please Select--</option> <option class="open" value="for sale" <?php if($house_info['status'] == 'for sale'){echo 'selected';}?>>For Sale</option> <option class="open" value="for rent" <?php if($house_info['status'] == 'for rent'){echo 'selected';}?>>For Rent</option> <option class="open" value="under negotiation" <?php if($house_info['status'] == 'under negotiation'){echo 'selected';}?>>Under Negotiation</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['statusEntry']) || !empty ($_SESSION['error_storage']['statusEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['statusEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['priceEntry']) || !empty ($_SESSION['error_storage']['propertyType2Entry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="price">Asking Price:</label> £ <input class="open" name="price" type="text" size="20" maxlength="15" id="price" value="<?php echo $house_info['valuation'];?>" /> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['priceEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['priceEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['noofbedEntry']) || !empty ($_SESSION['error_storage']['noofbedEntry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="noofbed">No. of Bedrooms:</label> <select class="open" name="noofbed" id="noofbed" onchange="this.selectedIndex>0?create_fields(Number(this.value),'bedrooms'):null;"> <option class="open" value="">--Please Select--</option> <option class="open" value="1" <?php if($house_info['num_bedrooms'] == '1'){echo 'selected';}?>>One</option> <option class="open" value="2" <?php if($house_info['num_bedrooms'] == '2'){echo 'selected';}?>>Two</option> <option class="open" value="3" <?php if($house_info['num_bedrooms'] == '3'){echo 'selected';}?>>Three</option> <option class="open" value="4" <?php if($house_info['num_bedrooms'] == '4'){echo 'selected';}?>>Four</option> <option class="open" value="5" <?php if($house_info['num_bedrooms'] == '5'){echo 'selected';}?>>Five</option> <option class="open" value="6" <?php if($house_info['num_bedrooms'] == '6'){echo 'selected';}?>>Six</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['noofbedEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['noofbedEntry'].'</span>'; }?> </div> </div> <div class="inputfield"> <div<?php if(!empty ($_SESSION['error_storage']['noofbathEntry']) || !empty ($_SESSION['error_storage']['noofbathEntry'])){ echo ' class="Emailerrorlabel"';} ?>> <label class="title" for="noofbath">No. of Bathrooms:</label> <select class="open" name="noofbath" id="noofbath" onchange="this.selectedIndex>0?create_fields(Number(this.value),'bathrooms'):null;"> <option class="open" value="">--Please Select--</option> <option class="open" value="1" <?php if($house_info['num_bathrooms'] == '1'){echo 'selected';}?>>One</option> <option class="open" value="2" <?php if($house_info['num_bathrooms'] == '2'){echo 'selected';}?>>Two</option> <option class="open" value="3" <?php if($house_info['num_bathrooms'] == '3'){echo 'selected';}?>>Three</option> <option class="open" value="4" <?php if($house_info['num_bathrooms'] == '4'){echo 'selected';}?>>Four</option> <option class="open" value="5" <?php if($house_info['num_bathrooms'] == '5'){echo 'selected';}?>>Five</option> <option class="open" value="6" <?php if($house_info['num_bathrooms'] == '6'){echo 'selected';}?>>Six</option> </select> <?php //if an email has not been entered then output emailEntry error if (!empty ($_SESSION['error_storage']['noofbathEntry'])){ echo '<img src="/images/warningtriangle.png" alt=""><br /><span class="Emailerrortextlabel">'.$_SESSION['error_storage']['noofbathEntry'].'</span>'; }?> </div> </div> <br /> <h7 class="formHeader">Room details</h7> <div class="inputfield"> <p class="largeblack"><strong>Living Room</strong></p> <div class="dimensions"> <label class="room" for="livingroom_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <?php if($function == 'edit'){ $liv_query = mysql_query("SELECT room_width,room_length,description FROM rooms WHERE room_name = 'Living Room' AND house_id = '$house_id'"); $din_query = mysql_query("SELECT room_width,room_length,description FROM rooms WHERE room_name = 'Dining Room' AND house_id = '$house_id'"); $liv_rec = mysql_fetch_array($liv_query); $din_rec = mysql_fetch_array($din_query); }?> <input class="open" name="livingroom_width" id="livingroom_width" type="text" size="5" value="<?php echo $liv_rec['room_width'];?>" /> x <input class="open" name="livingroom_length" id="livingroom_length" type="text" size="5" value="<?php echo $liv_rec['room_length'];?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="livingroom_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="livingroom_desc" id="livingroom_desc" size="100" cols="35" rows="5" ><?php echo $liv_rec['description'];?> </textarea> </div> </div> <div class="inputfield"> <p class="largeblack"><strong>Dining Room</strong></p> <div class="dimensions"> <label class="room" for="diningroom_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="diningroom_width" id="diningroom_width" type="text" size="5" value="<?php echo $din_rec['room_width'];?>" /> x <input class="open" name="diningroom_length" id="diningroom_length" type="text" size="5" value="<?php echo $din_rec['room_length'];?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="diningroom_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="diningroom_desc" id="diningroom_desc" size="100" cols="35" rows="5"><?php echo $din_rec['description'];?> </textarea> </div> </div> <div class="inputfield"> <img style="float:right;" src="Images/addRoom.png" alt="add another room" onclick="<?php echo 'generate_room();';$clickCount++;?>" /> <img id="deleteRoom" style="float:right; visibility:hidden; padding-right:4px;" src="Images/deleteRoom.png" alt="delete added room" onclick="remove_room('inputfield');" /> </div> <div id="rooms"><!--Start of rooms div--> </div><!--End of rooms div--> <br /> <div id="bedrooms"> <h7>Bedroom details</h7> <?php if($function == 'edit'){ $sql = "SELECT * FROM bedrooms WHERE house_id = '$house_id'"; $result = mysql_query($sql) or die("Failed to query bedrooms: ".mysql_error()); while($row = mysql_fetch_assoc($result)){ ?> <div class="inputfield"> <p class="largeblack"><strong>Bedroom_1</strong></p> <div class="dimensions"> <label class="room" for="bedrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="<?php echo htmlspecialchars($row['room_width']) ?>" /> x <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="<?php echo htmlspecialchars($row['room_length']) ?>" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bedrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bedrooms[1][]" id="bedrooms[1][]" size="100" cols="35" rows="5"><?php echo htmlspecialchars($row['description']) ?></textarea> </div> </div> <?php } }else{ ?> <div class="inputfield"> <p class="largeblack"><strong>Bedroom_1</strong></p> <div class="dimensions"> <label class="room" for="bedrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="" /> x <input class="open" name="bedrooms[1][]" id="bedrooms[1][]" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bedrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bedrooms[1][]" id="bedrooms[1][]" size="100" cols="35" rows="5"></textarea> </div> </div> </div> <br /> <div id="bathrooms"> <h7>Bathroom details</h7> <div class="inputfield"> <p class="largeblack"><strong>Bathroom_1</strong></p> <div class="dimensions"> <label class="room" for="bathrooms[1][]">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="bathrooms[1][]" id="bathrooms[1][]" type="text" size="5" value="" /> x <input class="open" name="bathrooms[1][]" id="bathrooms[1][]" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="bathrooms[1][]">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="bathrooms[1][]" id="bathrooms[1][]" size="100" cols="35" rows="5">Enter your description here..... </textarea> </div> </div> </div> <br /> <h7>Extra Details</h7> <div class="inputfield"> <p class="largeblack"<strong>Garden</strong></p> <div class="dimensions"> <label class="room" for="garden_width">Dimensions:<br/> <span class="textSmallGreen">(in feet)</span> </label> <input class="open" name="garden_width" id="garden_width" type="text" size="5" value="" /> x <input class="open" name="garden_width" id="garden_length" type="text" size="5" value="" /> </div> <div class="descriptionHolder"> <label class="room" style="width:90px;" for="garden_desc">Description:<br/> <span class="textSmallGreen">(max. 100 words)</span> </label> <textarea class="open" name="garden_desc" id="garden_desc" size="100" cols="35" rows="5">Enter your description here..... </textarea> </div> </div> <br /> <h7>Overall Description</h7> <div class="inputfield"> <p class="largeblack"><strong>Property Description</strong></p> <p class="largeblack">This is your opportunity to really sell your house and make it sound as wonderful as possible!<br />You have 200 words to describe your house as a whole, giving details of features, entrances, style etc......<strong>good luck!</strong></p> <textarea class="open" style="position:relative;left:-90px;" name="property_desc" id="property_desc" cols="70" rows="5">Enter your description here..... </textarea> </div> <br /> <input type='hidden' name='added_rooms' value='<?php echo $clickCount ?>'/> <input name="Submit" type="image" align ="right" src="Images/NextButton.png" /> </form> </div> </div> <div class="Redwindowbottom"><span></span></div> </div> </div><!--End of content-bodycontent"--> </div> <div id="footer"> <ul id="footerMenu"> <li><a class="small" href="ConstructionPage.html">Go4home terms & conditions</a></li> <li><a class="small" href="ConstructionPage.html">Accessibility</a></li> <li><a class="small" href="ConstructionPage.html">About Us</a></li> <li><a class="small" href="ConstructionPage.html">Privacy Policy</a></li> <li><a class="small" href="ConstructionPage.html">Contact Us</a></li> </ul> <br /> <p class="copyright">© Go4home.co.uk 2007</p> <ul id="validationMenu"> <li><a href="http://jigsaw.w3.org/css-validator/"><img src="Images/vcss-blue.png" alt="Valid CSS!" /></a></li> <li><a href="http://validator.w3.org/check?uri=referer"><img src="Images/vxhtml.png" alt="Valid XHTML 1.0 Transitional!"/></a></li> </ul> </div> </div><!--End of mainContainer--> </body> </html> so if you want have a look through that..i think the method that you have suggested will work, and i don't know why i didn't think of doing that sooner, i guess i got side tracked with using the javascript with php thing and wanted to solve that, when i could made things a lot easier for myself! just let me know if have any questions about the code, hopefully you can get an idea of what i'm tyring to do by looking at this code.. cheers Craig
  12. Hey, Ok, feel slightly thick at this moment...... You see i used javascript to clone my fields when they upload their house details, in this case they are editing their house, so what i am doing is storing a variable in the url when go to edit the property, so if that variable (function='edit') is edit then it gets all the data from the database and displays it when the page is loaded, so they can see what they have entered, and if any changes are made, the database is updated accordingly. So i got stuck into the notation of re-using my code, hence why i was trying to do exactly what you have done, but calling the javascript within the while loop, which obviously can't be done.... Argggh!! ok, i will give this a go, cheers!! Craig
  13. Hey, I'm not sure how i can do it with just php?!? Unless im totally missing something, i think i have been trying to sort this out for SO long, i have lost my mind AND my way a little bit... The fields are generated by javascript, and then for each room that is developed in that javascript has two input fields and one textarea. So i need to pull the data from the database for each bedroom, and then somehow put the 3 pieces of data for each room into the input fields and textrea, but i really don't know how i can achieve this? I know you can put an echo into the value="" of the input field, but somehow i need to loop through each bedroom....ahhhhhh i really don't know how to go about this... Do you know a way of doing this at all?? your help will be greatly received Cheers Craig
  14. Hey guys, Right, i will start with what i am trying to do. I have a javascript function which clones some HTML which i have on my page(which is some input fields) that allow a user to enter bedroom details of their house. This runs on the <body onload=""> tag, and works fine. But what i want to do is then fill these fields with data of the house, retrieved using mysql from my database. To go though each of the bedrooms on the database and fill in all the data in the fields requires a while loop to cycle through each bedroom and then add the data to each bedroom at a time... This is where my problem is, as i want to do this automatically when the page is loaded. Hence why i am looking at AJAX. I don't know a lot about AJAX, i have read w3schools stuff, and did a tutorial for the suggestion tool, which i understood, but can't understand how i can use that knowledge for my parrticular problem. How do i use AJAX to call my php script (while loop) and put the data into my input fields?? any help would be great, i have been mightily stuck on this for a while now cheers guys Craig
  15. Hey guys, Can anyone help me out with this problem?? really confused with how to use AJAX to call a php while loop and then call javascript functions within that.... cheers Craig
  16. Ok, What i have is a page called 'house_upload2.php'. Which is a page which the stage 2 of a 3 stage property upload system. Where a user uploads details and then uploads images to my database using mysql. What i am trying to do is create an edit property function where the user can go through all the steps again and change the property details. So what i want to do is use the same pages for my upload facility, but i have sent a variable along the url for the pages, where i use PHP to capture that variable using 'GET'. the variable is called function, and if they click to edit a property, the url would be as follows: 'propertyManager/house_upload2.php?function=edit' So i have if statements on my pages where if the $function variable is equal to edit, then it collects the property data from my database, so when the page loads, the input fields display the data of that property that they are editing!! Does that make sense??! i hope so! So on house_upload2.php, i had a function using javascript which when a user selects how many bedrooms is in their property from a drop down box, it generates the input fields and description box for that many rooms. So what i want to do, is if they are EDITING the property, i want to pull the number of bedrooms the property has, and then output the input boxes etc as before, but then put all the data for these rooms in those fields by taking the data from my database.... Obviously i tried to do this from when the page loads, i want it to do it automatically when the page is opened. But i need to somehow loop through each bedrooms data and put it in the right boxes.. Does that clear up what i'm trying to do?? Is this a case for AJAX? or am i missing something here? do i need basic php? i tried looking for examples of what i'm trying to do but couldn't find anything..... if you can provide some help that would be excellent! cheers Craig
  17. Hey PFMaBiSmAd! Ok, so i read up on AJAX, and did the tutorial where you have to create a suggestion box, which is cool! and i definitely want to use AJAX in the future, for form error checking? rather than going to a php page where the form is validated and returned to form page with errors stored in sessions....AJAX seems like a really useful tool.. However, i dont understand how i would use it in the case i need it to work?? don't suppose you can help me? What i need to do is in a while loop, go through each room in my mysql fetch array and then for each, generate a room, and then put the data from my mysql into it.... So i have a javascript page which has the function 'GetXmlHttpObject' to create the xmlHttp object. Then i would another method which preforms the create_fields() function and then the autofill() function to put the data in. But this needs to be done within a php while loop, how would i get the javascript to interact with this while loop? do i need to put the while loop in a variable and then return the variable into a javascript variable? I'm really confused here! any help would be great!! thanks Craig
  18. ok, so AJAX....don't suppose you could tell me what part of AJAX i would need to look into? or even a URL to a page which has the information on that i would need to research and look into?? I haven't really used AJAX much before, practicaly have 0% experience with AJAX. cheers Craig
  19. hey Neil, Yeah i have tried with an onClick event, and it works fine. But what i need it to so is run these commands auto when the page is loaded! Or is there another event handler which uses a pageload event? cheers Craig
  20. Hey guys, Been trying to sort this out for a couple of days now, with no prevail. What i am trying to do is call a php while loop within my body onload tag, which then calls javascript function within that while loop. But i cannot get it to work at all!! here's what i have so far, but it is just not working: <body onload="create_fields('1','bedrooms');<?php while($bedroom_data = mysql_fetch_array($query_bed)){ echo "autofill(".$bedroom_data['room_width'].",".$bedroom_data['room_length'].",'".$bedroom_data['description']."');"; }?> "> is what i am trying to here even possible? is the problem with calling the javascript functions within the php?? I have put an alert line in my functions to see if they are being called, and maybe a problem with the javascript, but its not that because the alerts aren't showing.. If anyone can help that would be great!! cheers Craig
  21. hey, That disn't work either!! really puzzled by this! i tried putting single quotations round all the variables in the echo statement as well, beed fiddling around with it for a little while and get it to work, but the source code suggests that it is working, but then nothing appears, not even the alert i put in the function to check that the function is called!! still no joy.. really stumped can there be another reason to this?! cheers Craig
  22. hey, yeah, this is what it generates: <body onload="create_fields('4','bedrooms');autofill(178,414,Enter your description here..... );autofill(556,889,Enter your description here..... );"> cheers Craig
  23. hey lemmin, Tried the code, and it didn't work unfortunately!! Tried changing it around etc, but it doesn't work...i really don't see why it wouldn't though? do you not have to echo the '<SCRIPT LANGUAGE='javascript'></SCRIPT>' tags when calling a function within php? is that why it may not be working? cheers Craig
  24. Hey lemmin, thanks for your reply...again!! the body onload function worked well. However, what i'm trying to do now, is when the fields are generated, i want to be able to autofill the input fields in with data from database using mysql..... so i have a js function in the head of my page called autofill(), which is shown as follows: function autofill(width,height,description) { document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = width; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = length; document.forms.namedItem('upload_stage2').elements.namedItem('bedroom[1][]').value = description; } So i call the js function after the create_fields() function, giving the width, height, and description of each of my rooms as parameters which the function can read in. so then for each room, the fields are generated, and then filled in from mysql data. So what i tried to do was put a php while loop on the body onload tag, and then call the javascript functions. Now, i don't have great knowledge of js, but i have called a javascript function from a php echo script before, and i also researched this, and it can be done. So this is what i came up with: <body onload="<?php while($bedroom_data = mysql_fetch_array($query_bed)){ echo "<SCRIPT LANGUAGE='javascript'>create_fields('1','bedrooms');autofill(".$bedroom_data['room_width'].",".$bedroom_data['room_length'].",".$bedroom_data['description'].");</SCRIPT>"; } echo '">';?> and of course, it doesn't execute. However i did look at my source code, and it shows the script being called, and with the parameters in there. But it isn't doing anything on screen. I have been looking at the code for a long while now, but can't seem to see where i'm going wrong. Can you helpme with this? or should i post it as a new topic?? cheers in advance, thanks for helping me out thus far Craig
  25. Hey Lemmin, I did what you said, and it actually works fine when it is assigned to a button.... So is there anyway that i can make the function work properly with assigning it to a button event? Like can you get the script to run when the page is loaded? like 'onBodyLoad'? cheers Craig
×
×
  • 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.