PHP - Drop Down Boxes
Hi
I have 3 drop down boxes and I want my boxes to go to another page when I select them and click go. For example if I click western cape I want it to give me all the resorts in western cape and if I click western cape and beaches I want it to give me all the resorts that are in the western cape that are next to beaches. I have been able to populate the drop down boxes with information and it can go to another page but it doesn't give me the information I want. This is my drop down boxes code Code: [Select] <script type="text/javascript"> function showGo(){ var region_id = $("#region_id").val(); var lifestyle_id = $("#lifestyle_id").val(); var resort_facility_id = $("#resort_facility_id").val(); if((region_id != 'false') || (lifestyle_id != 'false') || (resort_facility_id != 'false')){ $("#destinationSearchButton").css('display', 'block'); }else{ $("#destinationSearchButton").css('display', 'none'); } </script> <form action="/pages/search/" method="post"> <select class="formSelect" name="region_id" id="region_id" size="1" tabindex="1" onchange="showGo()"> <option label="Region"> <?php $regions_model = new regions_model('regions'); $regions = $regions_model -> get_all(); foreach($regions as $region){ $name = $region['name']; $id =$region['id']; $select = "SELECT $id, $name FROM regions"; echo "<option value='$id'>$name</option>"; } ?> </option> </select> <select class="formSelect" name="lifestyle_id" id="lifestyle_id" size="1" tabindex="2" onchange="showGo()"> <option label="lifestyle"> <?php $lifestyles_model = new lifestyles_model('lifestyles'); $lifestyles = $lifestyles_model -> get_all(); foreach($lifestyles as $lifestyle){ $name = $lifestyle['name']; $id = $lifestyle['id']; $select = "SELECT $name FROM lifestyles"; echo "<option name='$id'>$name</option>"; } ?> </option> </select> <select class="formSelect" name="resort_facility_id" id="resort_facility_id" size="1" tabindex="3" onchange="showGo()"> <option label="Facilities & Amenities"> <?php $resort_facilities_model = new resort_facilities_model('resort_facilities'); $resort_facilities= $resort_facilities_model -> get_all(); foreach($resort_facilities as $resort_facility){ $name = $resort_facility['name']; $id = $resort_facility['id']; $select = "SELECT $name FROM resort_failities"; echo "<option name='$id'>$name</option>"; } ?> </option> </select> <input class="formInputButton" type="submit" name="submitButtonName" id="destinationSearchButton" value="Go" tabindex="4"/ style="display: none;" /> </form> </div> Thank you Similar TutorialsHi all Im looking to do a "SIMPLE" search on a databse usign php. I want to have a drop down box like so : <select name="Lowest"> <option>0</option> <option>100</option> <option>200</option> </select> this is for the prices i want 2 of these so that the first will be the lowest price and the second will be the higher price Then i will make a query to SELECT * WHERE ( i dont know how to call the results from the select box here to display the whole tabled results ) any help please thnax Hey, I'm new to php and I made a webpage that searches a text file and displays a list of courses I've taken depending on what you type into a textbox. I want to change it instead into two drop-down boxes (one for department one for semester) and a all button so that it's neater and to prevent errors. Here is what I have currently: http://codepad.org/nX6g9zh2 Please help! Thank you! I have a shopping cart in the backend there is drop down for navigating through the categories and sub categories, but I'm looking for a better way as I have over 3 thousand categories! and I need a better and faster way to navigate the categories. Any ideas? Hello, I have the following function function make_agent_drop($dropname,$parent=''){ $agents = mysql_query("SELECT * FROM ad_category WHERE cat_status='1' AND parent_id='".(is_numeric($parent)?$parent:"0")."'") or die(mysql_error()); $anum = mysql_num_rows($agents); if($anum>0){ $agentdrop='<select style="width:150px; height:20px; margin-left:100px; font-size:11px;" name="'.$dropname.'" id="'.$dropname.'" class="text" '.(is_numeric($parent)?'':'onchange="update_subcatdrop($(this).val());').'"> <option value="0">Select a Category</option>'; while($row= mysql_fetch_array($agents)){ $agentdrop.='<option value="'.$row['cat_id'].'">'.$row['cat_name'].'</option>'; } $agentdrop.='</select>'; }else{ $agentdrop= 'No '.(is_numeric($parent)?'Sub':'').'Categories Found.'; } return $agentdrop; ; } I creates a drop down from database cats and sub cats.. I am trying to figure out how to add a submit button to dynamically appear when it displays the sub category... Thanks! Dan Hi All, I have 2 tables: one CarMake - CarMakeID - CarMakeDesc two CarModel - CarModelID - CarModelMake - CarModelDesc Depending on what the user selects in the first dropdown (carmake) the possible selection in the second dropdown (model) needs to be limited to only the models from the selected carmake. in the second table (Carmodel : the 'CarModelMake' = CarMakeID, to identify the make) How do I limit the dropdown 'CarModel' based on the selected CarMake in the first dropdown. link : http://98.131.37.90/postCar.php code : -- -- -- Code: [Select] <label> <select name="carmake" id="CarMake" class="validate[required]" style="width: 200px;"> <option value="">Select CAR MAKE...</option> <?php while($obj_queryCarMake = mysql_fetch_object($result_queryCarMake)) { ?> <option value="<?php echo $obj_queryCarMake->CarMakeID;?>" <?php if($obj_queryCarMake->CarMakeID == $CarAdCarMake) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarMake->CarMakeDesc;?></option> <?php } ?> </select> </label> <label> <select name="carmodel" id="CarModel" class="validate[required]" style="width: 200px;"> <option value="">Select MODEL...</option> <?php while($obj_queryCarModel = mysql_fetch_object($result_queryCarModel)) { ?> <option value="<?php echo $obj_queryCarModel->CarModelID;?>" <?php if($obj_queryCarModel->CarmodelID == $CarAdCarModel) { echo 'selected="selected"'; } ?> > <?php echo $obj_queryCarModel->CarModelDesc;?></option> <?php } ?> </select> </label> I'm a novice.. and appreciates all the help ! I am creating a form that will allow the user to select the make of vehicle "FORD" for example. If that make of vehicle is selected among different makes of vehicles, then another box will appear, with all the models for that particular model "Fiesta" for example. What type of code accomplishes this setup in my web page? I do not want to list 500 models in one drop down list, but just those for each make in the first drop down list. Thanks much! I am trying to add two search boxes to the below code. I need First Name, Last Name and Skill. I have added the boxes and connected fname (first_name) but am not sure how to link the other two correctly. Can anybody please help? I think it's something to do with the bold red text. Thanks <h3>Search Contacts Details</h3> <p>You may search either by first or last name</p> <form method="post" action="a.php?go" id="searchform"> <input type="text" name="fname"> <input type="text" name="lname"> <input type="text" name="skill"> <input type="submit" name="submit" value="Search"> </form> <?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['fname'])){ $fname=$_POST['fname']; //connect to the database $db=mysql_connect ("127.0.0.1", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //select the database to use $mydb=mysql_select_db("resource matrix"); //query the database table $sql="SELECT DISTINCT First_Name, Last_Name, l.Resource_ID FROM ((resource l inner join resource_skill ln on l.Resource_ID = ln.Resource_ID) inner join skill n on ln.Skill_ID = n.Skill_ID) WHERE First_Name LIKE '%" . $fname . "%' OR Last_Name LIKE '%" . $lname ."%' OR Skill_Name LIKE '%" . $skill ."%'"; Im having a problem in popup box.. i made a checkbox in a loop.. then after a success loop ive set a code for a popupbox. Code: [Select] echo '<script type="text/javascript"> {alert("Rejected!");} </script>'; But when a user checked 2 check boxes.. it would also popup a 2 popup box.. How can i make my code only popup once even if it selects multiple checkboxes? Hi, im new to php and got a simple query. i have built a web gallery and i want to add keywords to pictures, ive built the interface and mysql statements so it lists all possible keywords and creates a tick box for the user to use. ive created a table to join the image id's to my keyword id's as its going to be a many to many relationship, ive also built the sql statement below to select the highlighted image, but im not sure how i can join the looping of all keywords to generate the tick boxes and then to loop again to populate the tickboxes that are saved within the DB - if that makes sense?? SELECT * FROM images,img_key,keywords where img_key.img_id=images.id and keywords.id=img_key.key_id and images.id='2' I was using this wonderful tutorial on dynamic check boxes and databases http://www.phpfreaks.com/tutorial/working-with-checkboxes-and-a-database . This example is uses checkboxes to give users admin rites. I have tried to revamp this code to handle more inputs from checkboxes but some where I have made some errors. <?php include("db.php"); $updated = FALSE; if(count($_POST) > 0){ $DEP = $_POST['MMARS_DEP']; array_map('intval',$DEP); $DEP = implode(',',$DEP); mysql_query("UPDATE master_roles SET MMARS_DEPT=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_DEPT=1 WHERE id IN ($DEP)") or trigger_error(mysql_error(),E_USER_ERROR); $MD = $_POST['MMARS_MD']; array_map('intval',$MD); $MD = implode(',',$MD); mysql_query("UPDATE master_roles SET MMARS_MD=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_MD=1 WHERE id IN ($MD)") or trigger_error(mysql_error(),E_USER_ERROR); $ORG = $_POST['MMARS_ORG']; array_map('intval',$ORG); $ORG = implode(',',$ORG); mysql_query("UPDATE master_roles SET MMARS_ORG=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_ORG=1 WHERE id IN ($ORG)") or trigger_error(mysql_error(),E_USER_ERROR); $SEC = $_POST['MMARS_SEC']; array_map('intval',$SEC); $SEC = implode(',',$SEC); mysql_query("UPDATE master_roles SET MMARS_SEC=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_SEC=1 WHERE id IN ($SEC)") or trigger_error(mysql_error(),E_USER_ERROR); $BOG = $_POST['MMARS_BOG']; array_map('intval',$BOG); $BOG = implode(',',$BOG); mysql_query("UPDATE master_roles SET MMARS_BOG=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_BOG=1 WHERE id IN ($BOG)") or trigger_error(mysql_error(),E_USER_ERROR); $SW = $_POST['MMARS_SW']; array_map('intval',$SW); $SW = implode(',',$SW); mysql_query("UPDATE master_roles SET MMARS_SW=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_SW=1 WHERE id IN ($SW)") or trigger_error(mysql_error(),E_USER_ERROR); $updated=TRUE; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>phpfreaks checkbox tutorial</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <?php if($updated===TRUE){ echo '<div>Privileges Updated!</div>'; } ?> <table> <tr> <th><td>DEPT</td><td>MD</td><td>ORG</td><td>SEC</td><td>BOG</td><td>SW</td></th> <?php $label = array('MMARS','LCM','NM SEC','Classic MMARS','CAPS','PMIS','WRK COMP'); $table = array('MMars','LCM', 'NMSec', 'ClassMars', 'CAPS', 'PMIS', 'WrkComp'); $i= 0; while($i < 1){ echo "<tr>" ."<td>".$label[$i]."</td>"; $array = array(); $count = 0; $Aid = mysql_query("SELECT DISTINCT id FROM DB") or die (mysql_error()); while ($row= mysql_fetch_assoc($Aid)){ $ID = $row['id']."<br>"; $array[$count] = $ID; $count++; } $Disabled =""; $sql = "SELECT id, UAID, DB_NAME, MMARS_DEPT, MMARS_MD, MMARS_ORG, MMARS_SEC, MMARS_BOG, MMARS_SW FROM master_roles WHERE `UAID`='1000' AND id <= 6"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $row = mysql_fetch_row($result); list($id, $UAID, $DB_NAME, $MMARS_DEP, $MMARS_MD, $MMARS_ORG, $MMARS_SEC, $MMARS_BOG, $MMARS_SW)= $row; $checked = ($MMARS_DEPT==1) ? 'checked="checked"' : ''; echo '<td>'.$array[0].'<input type="checkbox" name="MMARS_DEP[]" value="'.$array[0].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_MD==1) ? 'checked="checked"' : ''; echo '<td>'.$array[1].'<input type="checkbox" name="MMARS_MD[]" value="'.$array[1].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_ORG==1) ? 'checked="checked"' : ''; echo '<td>'.$array[2].'<input type="checkbox" name="MMARS_ORG[]" value="'.$array[2].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_SEC==1) ? 'checked="checked"' : ''; echo '<td>'.$array[3].'<input type="checkbox" name="MMARS_SEC[]" value="'.$array[3].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_BOG==1) ? 'checked="checked"' : ''; echo '<td>'.$array[4].'<input type="checkbox" name="MMARS_BOG[]" value="'.$array[4].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_SW==1) ? 'checked="checked"' : ''; echo '<td>'.$array[5].'<input type="checkbox" name="MMARS_SW[]" value="'.$array[5].'" '.$checked.', '.$Disabled.' /></td>'; echo "</tr>"; $i ++; } ?> <tr><td colspan="2"><input type="submit" name="submit" value="Update Privileges" /></td></tr> </table> </form> </body> </html> After the post each individual checkbox input is saved into a variable then we query the database and check if any of the checkboxes have been changed to 1. If so then than right is updated to one. if(count($_POST) > 0){ $DEP = $_POST['MMARS_DEP']; array_map('intval',$DEP); $DEP = implode(',',$DEP); mysql_query("UPDATE master_roles SET MMARS_DEPT=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_DEPT=1 WHERE id IN ($DEP)") or trigger_error(mysql_error(),E_USER_ERROR); $MD = $_POST['MMARS_MD']; array_map('intval',$MD); $MD = implode(',',$MD); mysql_query("UPDATE master_roles SET MMARS_MD=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_MD=1 WHERE id IN ($MD)") or trigger_error(mysql_error(),E_USER_ERROR); $ORG = $_POST['MMARS_ORG']; array_map('intval',$ORG); $ORG = implode(',',$ORG); mysql_query("UPDATE master_roles SET MMARS_ORG=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_ORG=1 WHERE id IN ($ORG)") or trigger_error(mysql_error(),E_USER_ERROR); $SEC = $_POST['MMARS_SEC']; array_map('intval',$SEC); $SEC = implode(',',$SEC); mysql_query("UPDATE master_roles SET MMARS_SEC=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_SEC=1 WHERE id IN ($SEC)") or trigger_error(mysql_error(),E_USER_ERROR); $BOG = $_POST['MMARS_BOG']; array_map('intval',$BOG); $BOG = implode(',',$BOG); mysql_query("UPDATE master_roles SET MMARS_BOG=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_BOG=1 WHERE id IN ($BOG)") or trigger_error(mysql_error(),E_USER_ERROR); $SW = $_POST['MMARS_SW']; array_map('intval',$SW); $SW = implode(',',$SW); mysql_query("UPDATE master_roles SET MMARS_SW=0") or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("UPDATE master_roles SET MMARS_SW=1 WHERE id IN ($SW)") or trigger_error(mysql_error(),E_USER_ERROR); The html is a straight forward form. I have arrays set up and while loop ready for implementation because I plan on having this repeat multiple times. ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>phpfreaks checkbox tutorial</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <?php if($updated===TRUE){ echo '<div>Privileges Updated!</div>'; } ?> <table> <tr> <th><td>DEPT</td><td>MD</td><td>ORG</td><td>SEC</td><td>BOG</td><td>SW</td></th> <?php $label = array('MMARS','LCM','NM SEC','Classic MMARS','CAPS','PMIS','WRK COMP'); $table = array('MMars','LCM', 'NMSec', 'ClassMars', 'CAPS', 'PMIS', 'WrkComp'); $i= 0; while($i < 1){ echo "<tr>" ."<td>".$label[$i]."</td>"; I had a lot of problems keeping the id unique for each checkbox. This is why I created an array with the ids and I use them as "value" in the input field. $array = array(); $count = 0; $Aid = mysql_query("SELECT DISTINCT id FROM DB") or die (mysql_error()); while ($row= mysql_fetch_assoc($Aid)){ $ID = $row['id']."<br>"; $array[$count] = $ID; $count++; } I sql the database for id, UAID, DB_NAME, and all of the necessary rites. With list I assign each row with the correct name. Each checkbox's associated field in the db is checked to see if it is set to 1. If it is checked="checked". $sql = "SELECT id, UAID, DB_NAME, MMARS_DEPT, MMARS_MD, MMARS_ORG, MMARS_SEC, MMARS_BOG, MMARS_SW FROM master_roles WHERE `UAID`='1000' AND id <= 6"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $row = mysql_fetch_row($result); list($id, $UAID, $DB_NAME, $MMARS_DEPT, $MMARS_MD, $MMARS_ORG, $MMARS_SEC, $MMARS_BOG, $MMARS_SW)= $row; $checked = ($MMARS_DEPT==1) ? 'checked="checked"' : ''; echo '<td>'.$array[0].'<input type="checkbox" name="MMARS_DEP[]" value="'.$array[0].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_MD==1) ? 'checked="checked"' : ''; echo '<td>'.$array[1].'<input type="checkbox" name="MMARS_MD[]" value="'.$array[1].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_ORG==1) ? 'checked="checked"' : ''; echo '<td>'.$array[2].'<input type="checkbox" name="MMARS_ORG[]" value="'.$array[2].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_SEC==1) ? 'checked="checked"' : ''; echo '<td>'.$array[3].'<input type="checkbox" name="MMARS_SEC[]" value="'.$array[3].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_BOG==1) ? 'checked="checked"' : ''; echo '<td>'.$array[4].'<input type="checkbox" name="MMARS_BOG[]" value="'.$array[4].'" '.$checked.' , '.$Disabled.' /></td>'; $checked = ($MMARS_SW==1) ? 'checked="checked"' : ''; echo '<td>'.$array[5].'<input type="checkbox" name="MMARS_SW[]" value="'.$array[5].'" '.$checked.', '.$Disabled.' /></td>'; I am attaching a print out of my joined table I am querying as well as my final vision for this form. In advance, thank you for your help. I want to create a calculator that allows you to type in how many pieces of data you have, or how many averages you have. Once that is done, the amount of boxes pop up correctly - and you can enter in your data. But how can I get all those pieces of data from EACH box using one form? Current Example: http://novacms.vacau.com/ Code: <?php $boxes = $_POST['input']; if(!$boxes) { echo '<b>How many pieces of data do you have?</b> <form action="index.php" method="POST"><input type="text" name="input"><input type="submit"></form><br/><font size="2">Ex: 88.8,92.3,76.5 - That would be 3 pieces of data</font>'; } else { echo '<form action="index.php" method="POST">'; for($i = 0; $i <= $boxes; $i++) { echo '<input type="text"><br/>'; } echo '<input type="submit" value="Get average"></form>'; } ?> I am trying to figure out how to display member records after selecting it from the box. I've got the dropdown box working which retrieves the members name but cannot figure out how to populate that members details on the same page? I'm using php/mysql and although I want to display the records I also want a user to update that record aswell, creating it for administrators to update accounts? Any help would be appreciated I've researched that ajax or javascript might be helpful but not totally familiar with them. I have a form that contains radio buttons and when it is submitted the content of the form are added to a database. I was wondering how you get the values of radio boxes when submitting the form. I have the following radio buttons and when submitting I use "$_POST['article_type']" but this doesn't seem to work. Thanks for any help. <label>PDF Article</label><input name="article_type" value="pdf" type="radio" /> <label>Video Webcast</label><input name="article_type" value="webcast" type="radio" /> <label>Podcast</label><input name="article_type" value="podcast" type="radio" /> Is it possible to have multiple check boxes on a single form and a single submit button tp post the values into different rows of DB Kenny Hi guys On the edit profile page on my website, im trying to get is so that when the user first opens the page, if the database field reads "1" the checkbox is checked. However if the user unchecks it and makes a mistake on the form which returns an error, the checkbox remains unchecked. Also if the user unchecks the text box, the 1 in the database is changed to a 0. And vise versa. The only way i have got it to work succesfully is by using the following: <?php $test = $_POST['test']; $submit = $_POST['submit']; if (!isset($test)) { $test="0"; } else { $test="1"; } if ($submit) { mysql_query("UPDATE profiles SET test='$test' WHERE username='user'"); echo "ok"; } ?> <html> <form action="test.php" method="POST"> <input type="checkbox" name="test" <?php if ($submit) { if ($test=="1") { echo "checked='checked'";}} else { if ($row['test'] == "1") {echo "checked='checked'";}} ?> /> <input type="submit" name="submit" /> </form> </html> My problem is, i have about 60 check boxes on the page, and i dont really want to write the code below for all of them: if (!isset($test)) { $test="0"; } else { $test="1"; } Does anybody know a better way to do this so i dont end up with 420 lines of extra code? Many thanks. Hey guys,
My problem is, iam loading with mysql_fetch_array a table from my database and draw it into my website page.
The table is a user table which has an id, user, password and rights(Admin, Mod , User).
Only the rights are given out as <select> </select> boxes with the 3 options(Admin, Mod , User).
And i also have 1 more column which has for each row a href to a new site with the id of the array_index as paramter.
My Problem is i want to know which select box was changed and which option is selected so i can change the rights in my database of this user with the right id.
At the moment i cant post the code in here cause i have a problem with my laptop now.
I hope you can help me,
Thank you
Edited by Kandey, 30 October 2014 - 02:28 PM. I cannot figure out why my checkbox values are not being included in my emails I am posting my html and my php.
<form method="post" action="../leaf.php"> <input type="hidden" name="subject" value="Cleanup"> <div> <table width="425" border="0" cellspacing="0" cellpadding="0"> <tr> <td><label><span class="ie7bugfix01">Name:<span class="colour">*<br /> </span></span> <input type="text" name="contact-name" class="text" value="" /></label></td> <td><label><span class="ie7bugfix01">Email:<span class="colour">*</span></span><br /> <input type="text" name="contact-email" class="text" value="" /></label></td> </tr> <tr> <td> <label><span class="ie7bugfix01">Phone No:</span> <br /> <input type="text" name="contact-mobile" class="text" value="" /></label> </td> </tr> <tr> <td><label><span class="ie7bugfix01">Address:<br /> </span> <input type="text" name="contact-street" class="text" value="" /></label></td> <td><label><span class="ie7bugfix01">City:</span><br /> <input type="text" name="contact-city" class="text" value="" /></label></td> </tr> <tr> <td><label><span class="ie7bugfix01">Property Size:<br /> </span> <input type="text" name="property-size" class="text" value="" /></label></td> </tr> <tr> <td><label><span class="ie7bugfix01">Service request:</span><br /></label> <input type="checkbox" name="projects[]" value="Lawn Maintenance"> <label for="type1">Lawn Maintenance</label> <br> <input type="checkbox" name="projects[]" value="Mulching"> <label for="type2">Mulching</label> <br> <input type="checkbox" name="projects[]" value="Gutter Cleaning/Repair"> <label for="type3">Gutter Cleaning/Repair</label> <br> <input type="checkbox" name="projects[]" value="Revitalization"> <label for="type1">Revitalization</label> <br> <input type="checkbox" name="projects[]" value="Power Washing"> <label for="type2">Power Washing</label> <br> </td><td> <br> <input type="checkbox" name="projects[]" value="Hardscapes"> <label for="type3">Hardscape</label> <br> <input type="checkbox" name="projects[]" value="Deck Work"> <label for="type3">Deck Treatments/Repair/Construction</label> <br> <input type="checkbox" name="projects[]" value="Snow Removal"> <label for="type3">Snow Removal</label> <br><input type="checkbox" name="projects[]" value="Tree Trimming"> <label for="type3">Tree Trimming/Removal</label> <br> <input type="checkbox" name="projects[]" value="Privacy Barriers"> <label for="type3">Privacy Barriers</label> </td></tr> <tr> </tr> </table> <label><span class="ie7bugfix01">Describe your project:<span class="colour">*</span></span><br /> <textarea name="contact-comments" class="text" cols="68" rows="5"></textarea></label> <p class="submit"> <input type="submit" class="submit" value="submit" /> <input type="button" class="reset" value="reset" /> </p> </div></form> <?php $from = $_REQUEST['contact-email'] ; $name = $_REQUEST['contact-name'] ; $subject = $_REQUEST['subject'] ; $headers = "From: $from"; $headers = "Subject: $subject"; $fields = array(); $fields{"subject"} = "Subject"; $fields{"contact-name"} = "Name"; $fields{"contact-email"} = "E-mail"; $fields{"contact-mobile"} = "Phone"; $fields{"contact-street"} = "Address"; $fields{"contact-city"} = "City"; $fields{"property-size"} = "Size"; $selectedProjects = 'None'; if(isset($_POST['projects']) && is_array($_POST['projects']) && count($_POST['projects']) > 0){ $selectedProjects = implode(', ', $_POST['projects']); } $body .= 'Selected Projects: ' . $selectedProjects; $fields{"contact-comments"} = "Message"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: t***@toma***.com"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. By choosing TOMA you will be able to enjoy your time off with the peace of mind that your lawn is always professionally serviced. Never worry about finding time to work in the lawn again and gain back at least 35 hours of summer this season! TOMA provides weekly as needed lawn maintenance for your home or business. We are dedicated to every detail of your unique lawn. We always arrive with sharp blades, we police your property and we make sure everything is left freshly groomed and clean. Easy to sign up, easy billing, invest in your home and time today! FREE ESTIMATES WHEN YOU CALL ________. If you have any more questions, please consult our website at www.t**.com or call _________ to get started."; if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a name, please go back and try again";} else { $send = mail("t***@t**.com", $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.**t.com/thank-you.html" );} else {print "We encountered an error sending your mail, please try again"; } } } ?> Hi There, Is there any way that I can get a select box to auto-select the value from a SQL query? For example, if I have a select box like this: Dave,Jon,Simon,Fred And a select statement that brings back the value of Fred then the select box (in HTML) would: <select name='people'><option>Dave</option><option>Jon</option><option>Simon</option><option selected='selected'>Fred</option></select> Same as if the name was Dave, or Simon etc etc. Hope that makes sense? Cheers Matt |