PHP - Multipule Drop Down Menus On An Update Page - How To Omit Unselected Fields
Hi I have an update page with multipule drop down menus, I am looking for a way to allow only the drop down menus that have been altered to be sent to the database. One way was to add the following code, where the $type_id equals 0 then add nothing to the database.
Code: [Select] if ($type_id == 0) { $type_id = ""; } However I am getting a syntex error with this, if I enter a value into the $type_id it selects that fine. eg. Code: [Select] if ($type_id == 0) { $type_id = "2"; } What is the right way to send nothing to the database? Fuller code of the page is here <?php require_once("includes/sessions.php"); ?> <?php require_once("includes/connections.php"); ?> <?php require_once("includes/functions.php"); ?> <?php confirm_logged_in();?> <?php usersid(); ?> <?php find_selected_event(); find_selected_region(); ?> <?php $selected_event = getevent_byid ($url_eventid); $orgdescrip = orgdescription($url_eventid); $leveldescrip = leveldescription($url_eventid); $typedescrip = typedescription($url_eventid); $champdescrip = champdescription($url_eventid); $disdescrip = disdescription($url_eventid); $venuedescrip = venuedescription($url_eventid); $statusdescrip = statusdescription($url_eventid); ?> <?php if (!isset($new_event)) {$new_event = false;} ?> <?php // make sure the subject id sent is an integer if (intval($_GET['url_eventid']) == 0) { redirect_to('controlpanel.php'); } include_once("includes/form_functions.inc.php"); // START FORM PROCESSING // only execute the form processing if the form has been submitted if (isset($_POST['submit'])) { // initialize an array to hold our errors $errors = array(); // perform validations on the form data $required_fields = array('title'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); $required_numberfields = array(); $errors = array_merge($errors, check_number_fields($required_numberfields, $_POST)); $fields_with_lengths = array(); $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST)); // clean up the form data before putting it in the database $url_eventid = mysql_prep($_GET['url_eventid']); $user_id = mysql_prep($_POST['user_id']); $title = trim(mysql_prep($_POST['title'])); $event_details = mysql_prep($_POST['event_details']); $type_id = mysql_prep($_POST['type_id']); $champ_id = mysql_prep($_POST['champ_id']); $dis_id = mysql_prep($_POST['dis_id']); $org_id = mysql_prep($_POST['org_id']); $venue_id = mysql_prep($_POST['ven_id']); $level_id = mysql_prep($_POST['level_id']); $status_id = mysql_prep($_POST['status_id']); if ($type_id == 0) { $type_id = ""; } // Database submission only proceeds if there were NO errors. if (empty($errors)) { $sql = "UPDATE events SET \n" . "title = '{$title}',\n" . "event_details = '{$event_details}',\n" . "type_id = {$type_id},\n" . "champ_id = {$champ_id},\n" . "dis_id = {$dis_id},\n" . "org_id = {$org_id},\n" . "ven_id = {$venue_id},\n" . "user_id = {$url_userid},\n" . "level_id = {$level_id},\n" . "status_id = {$status_id}\n" . "WHERE event_id = {$url_eventid} \n" . "LIMIT 1"; if ($result = mysql_query($sql, $connection)) { // as is, $message will still be discarded on the redirect $message = "The event was successfully updated."; // get the last id inserted over the current db connection $new_event_id = mysql_insert_id(); redirect_to("newevent.php"); } else { $message = "I am sorry but the event could not be updated."; $message .= "<br />" . mysql_error(); } } else { if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were " . count($errors) . " errors in the form."; } } // END FORM PROCESSING } ?> <?php /*THIS CODE WITH RETURN IN THE BROWSER THE URLS THAT ARE BEING PULLED DOWN*/ if(empty($_GET)) echo "No GET variables"; else print_r($_GET); ?> <?php include("includes/header.inc.php"); ?> <title>Horse Events</title> <?php include_once("includes/meta.inc.php");?> <?php include_once("includes/cssfavgoogle.inc.php");?> <link href="css/adminpanel.css" rel="stylesheet" type="text/css" /> <style> input[type="number"] { width:40px; } </style> </head> <body> <div id="wrapper"> <div id="header"> <img src="images/horseevents_wheretogo.png" align="right" /> <?php require_once ("includes/adminmenu.inc.php"); ?> </div> <div id="adminleft"> <h2>YOUR UPCOMING EVENTS <?php echo "<a href=\"newevent.php?url_userid={$url_userid}\"><img src=\"images/pink/add_event.png\" align=\"right\" width=\"131\" height=\"19\" /></a>" ?></h2> <table id="datetable" width="300" border="0" > <?php $event_users_set = get_upcomingeventsforuser ($url_userid); while ($eventid = mysql_fetch_array ($event_users_set)){ echo"<tr class=\'date\'>"; echo"<td>" . $eventid["stdate"] ."</td>"; echo"<td><a href=\"editevent.php?url_userid={$url_userid}&url_eventid=". urlencode ($eventid['event_id']) . "\">". $eventid ['title'] . "</td>"; echo"</tr></a>"; } ?> </table> <br /> <h2>YOUR PAST EVENTS</h2> <table id="datetable" width="300" border="0" > <?php $event_users_set = get_pasteventsforuser ($url_userid); while ($eventid = mysql_fetch_array ($event_users_set)){ echo"<tr class=\'date\'>"; echo"<td>" . $eventid["stdate"] ."</td>"; echo"<td><a href=\"editevent.php?url_userid={$url_userid}&url_eventid=". urlencode ($eventid['event_id']) . "\">". $eventid ['title'] . "</td>"; echo"</tr></a>"; } ?> </table> </div> <div id="admincontent"> <span class="h1pln">Edit Your Event</span><a class="delete" href="deleteevent.php?url_eventid=<?php echo $url_eventid; ?>" onClick="return confirm('Are you sure you want to delete?')">Delete</a><br /> <span class="h3pln">Please make sure you complete all the compulary fields<span class="compuls">*</span>.<br /> The more accurately you enter your event the more people will be able to then find it. <br /> <br /> If there are any selections we do not currently have available please click here and I will add them to your drop down menus.</span> <?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?> <?php if (!empty($errors)) { display_errors($errors); } ?> <form id="newevent" action="editevent.php?url_eventid=<?php echo urlencode ($selected_event ['event_id']); ?>" method="post"> <table id="neweventdisplay" cellpadding="5" width="400" border="0"> <tr> <td><input type="text" name="event_id" value="<?php echo $url_eventid; ?>" /></td> <td><input type="text" name="user_id" value="<?php echo $url_userid; ?>" /></td> </tr> <tr> <td class="heading">Event Title</td> <td><input id="titleinput" name="title" type="text" value="<?php echo $selected_event ['title']; ?>" /><span class="compuls">*</span><span class="smalltext">Enter up to 36 characters</span></td> </tr> <tr> <td class="heading">Current Status</td> <td><?php echo $statusdescrip ['status_description']; ?> <select name="status_id" > <?php $status_set = findstatus(); $statuslist = mysql_fetch_assoc ($status_set); ?> <?php do { ?> <option value="<?php echo $statuslist ['status_id']; ?>" ><?php echo $statuslist ['status_description']; ?></option> <?php } while ($statuslist = mysql_fetch_assoc ($status_set)); ?></select> <span class="compuls">*</span></td> </tr> <tr> <td class="heading">Organiser</td> <td><?php echo $orgdescrip ['org_name']; ?> <select name="org_id"> <?php $organisers_set = findorganisers(); $orglist = mysql_fetch_assoc ($organisers_set); ?> <?php do { ?> <option value="<?php echo $orglist ['org_id']; ?>" ><?php echo $orglist ['org_name']; ?></option> <?php } while ($orglist = mysql_fetch_assoc ($organisers_set)); ?></select></td> </tr> <tr> <td class="heading">Start Date</td> <td id="dateinput"><?php echo $selected_event ['stdate']; ?></td> </tr> <tr> <td class="heading">Type Of Event</td> <td><?php echo $typedescrip ['type_description']; ?> <select name="type_id"> <?php $type_set = findtype(); $typelist = mysql_fetch_assoc ($type_set); ?> <?php do { ?> <option value="<?php echo $typelist ['type_id']; ?>" ><?php echo $typelist ['type_description'], $typelist ['type_id']; ?></option> <?php } while ($typelist = mysql_fetch_assoc ($type_set)); ?></select><span class="compuls">*</span></td> </tr> <tr> <td class="heading">Venue</td> <td><?php echo $venuedescrip ['ven_name']; ?><select name="ven_id"> <?php $venues_set = findvenues(); $venuelist = mysql_fetch_assoc ($venues_set); ?> <?php do { ?> <option value="<?php echo $venuelist ['ven_id']; ?>" ><?php echo $venuelist ['ven_name'], $venuelist ['ven_id']; ?></option> <?php } while ($venuelist = mysql_fetch_assoc ($venues_set)); ?></select></td> </tr> <tr> <td class="heading">Discipline</td> <td><?php echo $disdescrip ['dis_description']; ?><select name="dis_id"> <?php $discipline_set = finddisciplines(); $dislist = mysql_fetch_assoc ($discipline_set); ?> <?php do { ?> <option value="<?php echo $dislist ['dis_id']; ?>" ><?php echo $dislist ['dis_description'], $dislist ['dis_id']; ?></option> <?php } while ($dislist = mysql_fetch_assoc ($discipline_set)); ?></select><span class="compuls">*</span></td> </tr> <tr> <td class="heading">Level</td> <td><?php echo $leveldescrip ['level_description']; ?> <select name="level_id"> <?php $level_set = findlevels(); $levellist = mysql_fetch_assoc ($level_set); ?> <?php do { ?> <option value="<?php echo $levellist ['level_id']; ?>" ><?php echo $levellist ['level_description'], $levellist ['level_id']; ?></option> <?php } while ($levellist = mysql_fetch_assoc ($level_set)); ?></select></td> </tr> <tr> <td class="heading">Is This A Championship</td> <td><?php echo $champdescrip ['champ_description']; ?><select name="champ_id"> <?php $championship_set = findchampionships(); $champlist = mysql_fetch_assoc ($championship_set); ?> <?php do { ?> <option value="<?php echo $champlist ['champ_id']; ?>" ><?php echo $champlist ['champ_description'], $champlist ['champ_id']; ?></option> <?php } while ($champlist = mysql_fetch_assoc ($championship_set)); ?></select></td> </tr> <tr> <td class="heading">Event Details</td> <td><textarea name="event_details" cols="45" rows="15" ><?php echo $selected_event ['event_details']; ?> </textarea></td> </tr> <tr> <td class="heading">Upload Schedule</td> <td></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" id="convert" value="Update Your Event"></td> </tr> </table> <a class="delete" href="controlpanel.php">Cancel</a> </form> </div> <div id="adminright"> </div> <br clear="all" /> <?php require("includes/lowerlistings.inc.php"); ?> <?php require("includes/footer.inc.php"); ?> </div><!--End of Wrapper--> </body> </html> Similar TutorialsBelow is the code I'm using, and I would like for when the information is sent to email that it omits empty fields including the field name. I'm not real sure on how to do this. Any help would be great!!!! Thanks!!!!! Code: [Select] ]<?php $SendFrom = "Form Feedback <feedback@yourdomain.com>"; $SendTo = "feedback@yourdomain.com"; $SubjectLine = "Feedback Submission"; $ThanksURL = "thanks.html"; //confirmation page foreach ($_POST as $Field=>$Value) $MsgBody .= "$Field: $Value\n"; $MsgBody .= "\n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n" . $_SERVER["HTTP_USER_AGENT"]; $MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES); //make safe mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom"); header("Location: $http://www.yourdomain.org"); ?> [/code I am using a WordPress theme that uses some of its own functions besides WP functions. Let me make clear from the start that when I say "Multiple Checkboxes" in the paragraphs below I am NOT talking about checkboxes that each hold a single value. I am talking about one Checkbox field that allows multiple values to be selected and puts those values into an array with one Name value and stores the output in a string in a single mysql table field. Right up front, what I need during the Edit Ad functions is the inbuilt function that will Delete the previous Array of values in any multiple checkbox when the ad is updated. Right now updating the ad works for every situation except NO values selected or for Unchecking all previously selected values in a Multiple Checkbox. If I have, for example, 4 checkboxes selected and unselect all of them before submitting the edited ad it will return the last saved array of values but not an Empty array with no checkboxes selected. This theme has a Form Builder with a Custom fields builder used by the admin to create forms for a classified ads website. According to which category of ad the Ad creation procedure will show different forms, with different fields. I had to manually create the capability to generate multiple checkboxes...so that the different multiple checkboxes when selected and updated to the mysql table might hold a variety of values in a comma-delimited array. That works fine. When the Ad is edited on its own page, (outside of the Wordpress admin dashboard) the problem is that if a user would uncheck all checkboxes in a particular multiple checkbox then the unselected state does not overwrite the previous array of values. What returns after editing is the previous selected values. I have tried jquery functions but none of them are working the way I had hoped. so one type of checkbox might have a hypothetical value like this "name="cp_checkbox_help[]" and if three options are selected then on submit the value could be--- name="cp_checkbox_help[Sunday,Monday,Tuesday]" I use implode and explode to store the array as comma separated and retrieve the array for editing or display. I guess I need to create a Null or empty value as a default that only changes when selections are made. But, since I use implode and explode to make the array "pretty" I don't know if simply specifying nothing will erase a whole array on update. Here is some of the code used to see how I get what I get-- This displays the checkboxes that I create and name and fill with different values-- case 'checkbox': ?> <?php $options = explode(',', $result->field_values); echo '<div id="checkboxes"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <th colspan="2" scope="col">' . $result->field_label. '</th> </tr>'; $myvals= explode(',', $post_meta_val); foreach ($options as $option) { { ?> <tr> <td width="4%"><input style="display:inline-block; float:left;" type="<?php echo $result->field_type; ?>" name="<?php echo $result->field_name; ?>[]" class="checkbox<?php if($result->field_req) echo ' required'?>" id="<?php echo $field_label; ?>" value="<?php echo $option; ?>" <?php foreach ($myvals as $myval) { if (in_array($myval, array($option), true)) {echo 'checked="yes"';}}?>/></td> <td width="96%"style="vertical-align:top; text-indent: 7px; text-align: left;" ><?php echo $option . '</td> </tr> ' ?> <?php } } echo ' </tr> </table></div><div class="clr"></div>'; break; Following is the main part of the code that updates the Ad form-- // update the ad and return the ad id $post_id = wp_update_post($update_ad); if($post_id) { // now update all the custom fields foreach($_POST as $meta_key => $meta_value) { if (cp_str_starts_with($meta_key, 'cp_')) if (cp_str_starts_with($meta_key, 'cp_checkbox_charley')) $meta_value= implode(',', $_POST['cp_checkbox_charley']); if (cp_str_starts_with($meta_key, 'cp_checkbox_help')) $meta_value = implode(',', $_POST['cp_checkbox_help']); if (cp_str_starts_with($meta_key, 'cp_checkbox_hello')) $meta_value= implode(',', $_POST['cp_checkbox_hello']); //echo $meta_key . ' <--metakey <br/>' . $meta_value . ' <--metavalue<br/><br/>'; // for debugging update_post_meta($post_id, $meta_key, $meta_value); } $errmsg = '<div class="box-yellow"><b>' . __('Your ad has been successfully updated.','cp') . '</b> <a href="' . CP_DASHBOARD_URL . '">' . __('Return to my dashboard','cp') . '</a></div>'; } else { // the ad wasn't updated so throw an error $errmsg = '<div class="box-red"><b>' . __('There was an error trying to update your ad.','cp') . '</b></div>'; } return $errmsg; } Back on the Edit Ad page this is the Submit <p class="submit center"> <input type="button" class="btn_orange" onclick="window.location.href='<?php echo CP_DASHBOARD_URL ?>'" value="<?php _e('Cancel', 'cp')?>" /> <input type="submit" class="btn_orange" value="<?php _e('Update Ad »','cp') ?>" name="submit" /> I have a feeling what I need is just a couple of lines to detect no posted values and then... but if one checkbox array has 6 values in it and another checkbox array has only 3 values, for example, do I need to count each specific checkbox for number of values and then overwrite or will one function completely delete the previous array and its commas? I would really appreciate some expert assistance here! Hi I was just wondering if someone could send me a good tutorial on pulling several fields from a table and displaying them all in one drop down menu for people to select one of them. I dont know what this is called to I dont know what to research online. I got some help here about 6 months ago with drop down menus & I need a little more. I'm working on a form that has about 20 drop down menus, each populated from a mysql database table with about 50 entries each. I need to keep the selected menu option on the form after the form is submitted but each time the form is submitted the selected menu option reverts back to the first item in the database table. Is there any practical way to fix this problem other than using javascript to finish up? I have this code: Code: [Select] if (isset($_POST['update'])){ $ids = implode(",", array_map('intval', $_POST['m'])); $ranks = implode(",", array_map('intval', $_POST['ranks'])); if ($ids < 1) message("Incorrect Data"); if ($ranks < 0) message("Incorrect Data"); echo $ids; echo "<br>"; echo $ranks; exit; $db->query('UPDATE friends set RANKS WHERE friend_id IN ('.$db->escape($ids).') AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); redirect("s.php?section=Friends","Thanks, Ranks Updated"); } I grab the id's from the rank This will spit out 3,4 for $ids and for $ranks, 1,2 as you can see, set for 1 and 2 respectivaly. My problem is how can I use MYSQL to update the data correspond to each id using a IN clause? Code: [Select] $db->query('UPDATE friends set RANKS = "LOST $RANKS? HERE" WHERE friend_id IN ('.$db->escape($ids).') AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); Hello everyone, I am trying triple drop down menu first and second menus are working but third one is not working and also the data is not being displayed on the webpage even though I have used "echo" command.. I am unsure what is the problem and how to correct it. So I am attaching my code in this email, could you please look into it and help me with it. I have 1st drop menu for State : Tennessee Alabama Georgia 2nd Drop down list for County: Anderson Bredford Benton 3rd Drop down list for Genus Acer Aristida Eg: Tennnesse -> Anderson, Bredford, Benton and Anderson -> Acer, Aristida and when I select Tennesse->Anderson->Acer it has to display all the information of the table based on these selected values. Could you please help me with this. This is my link for the complete code http://pastebin.com/vvLrpCcr The execution link is http://sozog.utc.edu/~tdv131/MYSQL/genus1c.htm Hi I have a single page submission update page which incorporates 7 drop down menus and 2 text input fields, everything works fine with the data updating back to the database, the only thing is that when the page is updated all the drop down menus are updated which includes ones that I don't want updated? I need to only update the drop down menus that have been selected? but am unsure how I do it? This is the code from the page, sorry if its a mess but I am not that experienced at the moment. This is a snippet of one of the drop down menus Code: [Select] <tr> <td class="heading">Current Status</td> <td><?php echo $statusdescrip ['status_description']; ?> <select name="status_id" > <?php $status_set = findstatus(); $statuslist = mysql_fetch_assoc ($status_set); ?> <?php do { ?> <option value="<?php echo $statuslist ['status_id']; ?>" ><?php echo $statuslist ['status_description']; ?></option> <?php } while ($statuslist = mysql_fetch_assoc ($status_set)); ?></select> <span class="compuls">*</span></td> </tr> I'm simply trying to set up a form where, if when a user clicks 'Submit', and then 'Back', the values from the form are preserved. My question is, how do I preserve the values of drop down menus. The following is a snippet of my code: Code: [Select] <select name="dropdown_dept" id="dept_list"> <option value=0><?php echo "Please select one..."?></option> <?php $dropdown_dept = "select dept_name from departments"; $result_dept = $db_conn->query($dropdown_dept); if (!$result_dept) { echo '<p>Unable to get department data.</p>'; return false; } for($i=0; $i<$result_dept->num_rows; $i++) { $app_name_row = $result_dept -> fetch_array(); ?> <option><?php echo($app_name_row[0]); ?></option> <? } ?> </select> Above is where I have set up a drop down menu of departments. Given that code, how can I preserve the department name after a user clicks 'Submit'? I am trying to insert a date into a mySQL table from html drop downs with php. Right now when I enter the date it goes into the database as 0000-00-00. Can anybody see why it might be doing this? My html: Code: [Select] <label for='birthdate' >Birthdate (Optional):</label><br/> <select name='month' id='month' value='<?php echo $fgmembersite->SafeDisplay('month') ?>'> <option value="01" selected="January">January</option> <option value="02">February</option> <option value="03">March</option> etc... </select> <select name='day' id='day' value='<?php echo $fgmembersite->SafeDisplay('day') ?>'> <option value="01" selected="1">1</option> <option value="02">2</option> <option value="03">3</option> etc... </select> <select name='year' id='year' value='<?php echo $fgmembersite->SafeDisplay('year') ?>'> <option value="2010" selected="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> etc... </select> And my php to collect info: Code: [Select] $formvars['birthdate'] = $this->Sanitize($_POST['year'], $_POST['month'], $_POST['day']); php where I make table: Code: [Select] "birthdate DATE NOT NULL ,". php to insert into mysql: Code: [Select] $insert_query = 'insert into '.$this->tablename.'( name, address, birthdate, sex, program, guide, email, username, password, confirmcode ) values ( "' . $this->SanitizeForSQL($formvars['name']) . '", "' . $this->SanitizeForSQL($formvars['address']) . '", "' . $this->SanitizeForSQL($formvars['birthdate']) . '", "' . $this->SanitizeForSQL($formvars['sex']) . '", "' . $this->SanitizeForSQL($formvars['program']) . '", "' . $this->SanitizeForSQL($formvars['guide']) . '", "' . $this->SanitizeForSQL($formvars['email']) . '", "' . $this->SanitizeForSQL($formvars['username']) . '", "' . md5($formvars['password']) . '", "' . $confirmcode . '" )'; Thank you! HI All, I am writing a prepared statement to update some user information. Included in this table are the username and password fields. In this particular form, i dont want the user to have access to this information and have built a form that only shows what i want them to be able to change. The bit that i am not sure about is the prepared statement that i am writing. I am getting a boolean error suggesting that my prepare failed and i think this may be because i have not named every field in the table. To give an idea of the table fields i have pulled this from php my_admin (this is not the sql i am running) UPDATE `ssm_user` SET `user_id`=[value-1],`user_email`=[value-2],`user_password`=[value-3], `user_firstname`=[value-4],`user_lastname`=[value-5],`user_accountlevel`=[value-6], `user_mobile`=[value-7],`user_role`=[value-8],`user_lastlogondate`=[value-9] WHERE 1 my prepared statement is $stmt = $conn->prepare(" UPDATE ssm_user SET user_email=?, user_firstname=?, user_lastname=?, user_accountlevel=?, user_mobile=?, WHERE user_id = ? "); $stmt->bind_param('sssssi', $email, $fname, $lname, $accountlevel, $mobile, $uid); $stmt->execute(); return $stmt->affected_rows; Do i have to declare every field in the table or is there something that i am missing here. Ok, I have one database three tables. Table 1 is ncmr the main table where everything is to be entered. Table 2 is companies, where all the companies in pull down menu 1 is located. Table 3 is fabricators, where all the people who have had hands on the product are residing. I want the selected choices of table 2 and 3 to be inputed into table 1. I know this has to be possible, but I don't know how. I thought I wrote the code correctly, but it seems not. Can someone review my code and show me where my mistake is? Here is the page: http://kaboomlabs.com/PDI/post2.php Thanks. Code: [Select] <?php require_once('connectvars.php'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die('Error connecting to MySQL server.'); ?> <!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>PDI Non-Conforming Materials Report</title> <link rel="stylesheet" type="text/css" href="CSS/postie.css" /> </head> <body> <div id="logo"> <img src="images/PDI_Logo_2.1.gif" alt="PDI Logo" /> </div> <div id="title"> <h3 id="NCMR2">Non-Conforming Materials Report (NCMR)</h3> </div> <?php //Post Data if (isset($_POST['submit'])) { $ab = mysqli_real_escape_string($dbc,$_POST['ab']); $date = mysqli_real_escape_string($dbc,date('Y-m-d',strtotime ($_POST['date']))); $part = mysqli_real_escape_string($dbc,$_POST['part']); $rev = mysqli_real_escape_string($dbc,$_POST['rev']); $partdesc = mysqli_real_escape_string($dbc,$_POST['partdesc']); $ncmrqty = mysqli_real_escape_string($dbc,$_POST['ncmrqty']); $comp = mysqli_real_escape_string($dbc,$_POST['comp']); $ncmrid = mysqli_real_escape_string($dbc,$_POST['ncmrid']); $rma = mysqli_real_escape_string($dbc,$_POST['rma']); $jno = mysqli_real_escape_string($dbc,$_POST['jno']); $fdt = mysqli_real_escape_string($dbc,$_POST['fdt']); $cof = mysqli_real_escape_string($dbc,$_POST['cof']); $fab1= mysqli_real_escape_string($dbc,$_POST['fab1']); $fab2= mysqli_real_escape_string($dbc,$_POST['fab2']); $fab3= mysqli_real_escape_string($dbc,$_POST['fab3']); $non= mysqli_real_escape_string($dbc,$_POST['non']); $dis= mysqli_real_escape_string($dbc,$_POST['dis']); $comm= mysqli_real_escape_string($dbc,$_POST['comm']); $caad= mysqli_real_escape_string($dbc,$_POST['caad']); $po= mysqli_real_escape_string($dbc,$_POST['po']); $pod = mysqli_real_escape_string($dbc,date('Y-m-d',strtotime($_POST['pod']))); $dri = mysqli_real_escape_string($dbc,date('Y-m-d',strtotime($_POST['dri']))); $output_form = 'no'; if (empty($ab) || empty($date) || empty($part) || empty($partdesc)){ // We know at least one of the input fields is blank echo '<div id="alert">'; echo 'Please fill out all of the required NCMR information.<br />'; echo '</div>'; } $output_form = 'yes'; } //Access the Database if (!empty($ab) && !empty($date) && !empty($pod)) { $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die('Error connecting to MySQL server.'); $query = "INSERT INTO ncmr (ab, date, part, rev, partdesc, ncmrqty, comp, ncmrid, rma, jno, fdt, cof, fab1, fab2, fab3, non, dis, comm, caad, po, pod, dri) VALUES ('$ab','$date','$part','$rev','$partdesc','$ncmrqty','$comp','$ncmrid','$rma','$jno','$fdt','$cof','$fab1','$fab2','$fab3','$non','$dis','$comm','$caad','$po','$pod','$dri')"; $data = mysqli_query($dbc, $query) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $query"); // Confirm success with the user echo '<tr><td class="thank">'; echo '<p>Thank you for adding the NCRM, the correct person will be informed.</p>'; echo '<p><a href="post.php"><< Back to the form</a></p>'; $output_form = 'no'; echo '</td></tr>'; mysqli_close($dbc); } if ($output_form == 'yes') { echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>"; echo '<fieldset>'; //Part, Rev, Part Description, NCMR Qty echo '<div id="box1">'; echo '<div id="ab"><span class="b">Added By: </span><input type="text" name="ab" value="" /></div>'; echo '<div id="date"><span class="b">Date Filed: </span><input type="text" name="date" value="" /></div>'; echo '<div id="part"><span class="b">Part Number: </span><input type="text" name="part" value="" /></div>'; echo '<div id="rev"><span class="b">Part Revision: </span><input type="text" name="rev" value="" /></div>'; echo '<div id="partdesc"><span class="b">Part Description: </span><textarea name="partdesc" rows="3" cols="22" ></textarea></div>'; echo '<div id="ncmrqty"><span class="b">NCMR Qty: </span><input type="text" name="ncmrqty" value="" /></div>'; echo '</div>'; //Company, Customer NCMR, Internal RMA, and Job Number echo '<div id="box2">'; echo'<div id="comp">'; echo '<span class="b">Company: </span>'; $mysqli->select_db('comp'); $result = $mysqli->query("SELECT * FROM comp"); $i = 0; echo "<SELECT name='comp'>\n"; while($row = $result->fetch_assoc()) { if ($i == 4) echo '<option value="lines">-----</option>'; echo "<option value='{$row['user_id']}'>{$row['name']}</option>\n"; $i++; } echo "</select>\n"; echo '</div>'; echo '<div id="ncmrid"><span class="b">Customer NCMR ID: </span><input type="text" name="ncmrid" value="" /></div>'; echo '<div id="rma"><span class="b">Internal RMA #: </span><input type="text" name="rma" value="" /></div>'; echo '<div id="jno"><span class="b">Job #: </span><input type="text" name="jno" value="" /></div>'; echo '</div>'; //Type of Failure and Class of Failure echo '<div id="box3">'; echo '<h2>Failure</h2>'; echo '<div id="fdt">'; echo '<span class="b">Failure Due To: </span><br />'; echo '<select name="fdt">'; echo '<option value="none">----None----</option>'; echo '<option value="In House">In House</option>'; echo '<option value="Third Party">Third Party</option>'; echo '</select>'; echo '</div>'; echo'<div id="cof">'; echo '<span class="b">Class of Failu </span><br />'; echo '<select name="cof">'; echo '<option value="none">----None----</option>'; echo '<option value="Materials">Materials</option>'; echo '<option value="Fabrication">Fabrication</option>'; echo '<option value="Drawing">Drawing</option>'; echo '<option value="Assembly">Assembly</option>'; echo '<option value="Testing">Testing</option>'; echo '<option value="Electrical">Electrical</option>'; echo '<option value="Programming">Programming</option>'; echo '<option value="Machining">Machining</option>'; echo '<option value="Inspection">Inspection</option>'; echo '<option value="Purchasing">Purchasing</option>'; echo '<option value="Administrator">Administrator</option>'; echo '</select>'; echo '</div>'; echo '</div>'; //Fabricators echo '<div id="box4">'; echo '<h2>Fabricators</h2>'; echo'<div id="fab1">'; $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab1'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user_id']}'>{$row['user']}</option>\n";} echo "</select>\n"; echo '</div>'; echo'<div id="fab2">'; $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab2'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user_id']}'>{$row['user']}</option>\n";} echo "</select>\n"; echo '</div>'; echo'<div id="fab3">'; $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $mysqli->select_db('user'); $result = $mysqli->query("SELECT * FROM user"); echo "<SELECT name='fab3'>\n"; while($row = $result->fetch_assoc()) { echo "<option value='{$row['user_id']}'>{$row['user']}</option>\n";} echo "</select>\n"; echo '</div>'; echo '</div>'; //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box5">'; echo '<div id="non"><span class="b">Nonconformity: </span><br /><textarea name="non" rows="3" cols="110" ></textarea><br /></div>'; echo '<div id="dis"><span class="b">Disposition: </span><br /><textarea name="dis" rows="3" cols="110" ></textarea></div>'; echo '<div id="comm"><span class="b">Comments: </span><br /><textarea name="comm" rows="3" cols="110" ></textarea></div>'; echo '<div id="caad"><span class="b">Comments and/or Additional Details: </span><br /><textarea name="caad" rows="3" cols="110" ></textarea></div>'; //PO, PO Date, and Date Recieved echo '<div id="podr">'; echo '<div id="po"><span class="b">PO: </span><input type="text" name="po" size="7" value="" /></div>'; echo '<div id="pod"><span class="b">PO Date: </span><input type="text" name="pod" size="7" value="" /></div>'; echo '<div id="dri"><span class="b">Date Received: </span><input type="text" name="dri" size="7" value=""'; echo '</div>'; echo '<div id="button"><input type="submit" value="Submit NCMR" name="submit" /></div>'; echo '</div>'; echo '</fieldset>'; echo '</form>'; } ?> </body> </html> I have the following PHP script to update two time/date fields in the database. When i run this the fields are not updated. Can anyone see where i m going wrong. <?php $con = mysql_connect("localhost","dbname","dbpassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db("my_db", $con); mysql_query("UPDATE msm_content SET created = '2011-01-02 00:00:00', modified = '2011-01-01 00:00:00'"); echo 'Query Updated successfully'; mysql_close($con); ?> Your guidance is much appreciated. Now, here's what I'm trying to do:
First, I have a file filled with data like such:
title
tag
1
2
Title
Description
Etc
Next, I upload that file to my site which then proceeds to make an array with said data and then inserts it into my database. But this is not the intended behavior. Right now, if I upload the same file again, it will re-insert everything and duplicate all entries.
What I want to do is check if the data in the file has already been added, do nothing. If it's been modified, I want to update the database where changes have been made and not duplicate anything.
Currently, my code does all that except one thing whre I'm really stuck: it won't update the changes from the file to the database. I've tried echoing everything and it's to be working except for the query so I take it the error is in there but I can't find it... I'm still learning PHP and MySQL so I thought maybe somebody could help indicate where or what I'm doing wrong in the query. Thanks in advance !
Here's my attempt at doing so:
$register_ep_data = array( 'show' => $name, 'season' => $srNum, 'ep' => $epNum, 'app_name' => $epName, 'tag' => $tag, 'app_about' => $desc, 'app_website' => $imdb, 'app_release' => $release, 'type' => $type, 'app_code' => $Frame ); array_walk($register_ep_data, 'array_fu'); $fields = '`' . implode('`, `', array_keys($register_ep_data)) . '`'; $data = '\'' . implode('\', \'', $register_ep_data) . '\''; $epFound = false; $id = 0; while ($ep_list_data = mysql_fetch_array($turtle)) { $id = $ep_list_data['app_id']; $currentNAME = $ep_list_data['app_name']; $SERIES = $ep_list_data['show']; if ($SERIES == $name) { if ($currentNAME == $epName) { $epFound = true; break; } } } if ($epFound) { mysql_query("UPDATE `games` SET ($fields) VALUES ($data) WHERE `app_id` = '$id'"); } else { mysql_query("INSERT INTO `games` ($fields) VALUES ($data)"); }A few explanations: $fields would equal to something like: `show`, `season`, `ep`, etc... and $data to 'example', '1', '2', 'etc' HI, I have a user form on a modal. The user can be updated from this modal but on the second tab is where the users password can be updated. The update button commits all changes including the password update. If the New Password field is blank i do not want it to be updated. I am using a prepared statement and am not sure how to ommit a field if it is blank. In actual fact there is a new password and a confirm password field which must be the same before the password field is updated. if ($_SERVER['REQUEST_METHOD']=='POST'){ $uid = $_POST['UM-uid']; $fname = $_POST['UM-firstName']; $lname = $_POST['UM-lastName']; $email = $_POST['UM-emailAddress']; $accountlevel = $_POST['UM-accountLevelId']; $mobile = $_POST['UM-mobileNumber']; $roleid = $_POST['UM-roleId']; $newpass = password_hash($_POST['UM-pass'], PASSWORD_DEFAULT); if(!empty($_POST['UM-firstName'])){ // prepare stmt $stmt = $conn->prepare(" UPDATE ssm_user SET user_password=?, user_email=?, user_firstname=?, user_lastname=?, user_account_level_id=?, user_mobile=?, user_role_id=? WHERE user_id = ? "); $stmt->bind_param('sssssssi', $newpass, $email, $fname, $lname, $accountlevel, $mobile, $roleid, $uid); $stmt->execute(); $_SESSION['user']=$fname." ".$lname; $_SESSION['updateUser']="has been successfully updated"; $_SESSION['actionstatus']="success"; I am sure i will be able to work out the password confirmation part, its just the omitting password from being part of the update if blank. Hello people, thank you to everyone that has helped me on this forum. You have been terrific. I am submitting a form to a database and am having a small problem with the validation scripts. Basically if the user doesn't put something into one of the fields they get an error message. However, I am keeping the information already submitted in the input box with the following code Code: [Select] <input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'> This is so that the user doesn't have to input the same data again if he forgot one box. How do I do the same for "drop down" boxes? Here is the code from the form for the "ppr" (aviation terms 'Prior Permission Required') Code: [Select] <select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> The problem I have is that there are quite a number of these drop down boxes on the form I have created. And it always goes back to the first "option value" when there is an error. I do have a variable for $ppr, please could someone tell me how to incorporate it so that the user doesn't have to select the correct option value all over again. Hope my explanation is clear. Thanks in advance. So I have created an online test . I have the results from the form submitted to my email. It is working great but the only problem is that when a question is left unanswered, the radio button doesn't have a result. What i want it to do is when a question is left unanswered, the email should look like this (Question) 1_01: True 1_02: Unanswered 1_03: False 1_04: Unanswered 1_05: True Right now it looks like this: (Question) 1_01: True 1_03: False 1_05: True I can't make the radio button required because it is a timed test where you have to work fast, so unanswered questions are going to happen. How do I make it so that unanswered radio buttons submit the value "unanswered" in the E-mail? I am trying to update a mysql table called AvItems with the value 'Torso' in the Equip "section?" I have been through the forums and cannot see anything to match. I dont mind if the page looses the onsubmit() and has a button instead. Though I would like to update the database and link back to the same page: There is a display that shows the item that is currently equiped, I have put this in to show it works, or doesn't as the case may be. Hope I got the code /code right this time. many thanks in advance Andy Curtis Code: [Select] create table Items( ItemID integer unsigned auto_increment primary key, ItemName varchar(20) not null, Type varchar(10), UsedOn varchar(10), ); create table AvItems( AvItemID integer unsigned auto_increment primary key, AvID integer unsigned, ItemID integer unsigned, Equip varchar(8)); <?php $username="root"; $password="MyPassword"; $database="MyDataBase"; $AvName = "AndyJCurtis"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $AvAccR = mysql_query( " SELECT AvID FROM AvAcc WHERE AvName = '$AvName' " ); $AvID = mysql_result($AvAccR, 0, 'AvID'); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $Torso = mysql_query(" select ItemName from AvItems, Items where AvItems.itemID = Items.itemID AND AvItems.AvID = '$AvID' AND UsedON = 'Body' "); $TorsoE = mysql_query(" select ItemName from AvItems, Items where AvItems.itemID = Items.itemID AND AvItems.AvID = '$AvID' And UsedON = 'Body' AND Equip = 'Body' "); if(mysql_num_rows($TorsoE) != 0) { $TorsoItem = mysql_result($TorsoE ,0,"ItemName"); //mysql_close(); ?> <title></title> <head></head> <body> <form action="http://localhost/CI/Equip2.php" method="post"> <table border=1> <tbody> <tr> <td>Torso<BR> <?PHP echo "$TorsoItem <BR>"; ?> <select name="Torso" onchange="submit();" value =" Update"> <?PHP while($TorsoRow = mysql_fetch_array($Torso)) { echo "<option value=\"".$TorsoRow['ItemName']."\">".$TorsoRow['ItemName']."\n </option>"; } ?> </select> </td> </tr> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// <?php if($_POST['Torso'] == 'Update') { mysql_query("update AvItems set Equip = '' where Equip='Torso'") or die("cant update unequip"); mysql_query("update AvItems set Equip = 'Torso' where ItemID='{$_POST['ItemName']}'") or die("cant update equip"); } ?> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// </tbody> </table> </.form> </body> </html>
Hello I have an issue with a form that has been built by someone else on Wordpress. <div class="steps"> <div class="step gap-large step-1"> <h2 class="step-title"><span class="gold">Step 1.</span> Calculate the value of your <span class="gold">gold</span></h2> [gold_calculator your-items] </div> <div class="step gap-large step-2"> <h2 class="step-title"><span class="gold">Step 2.</span> Submit your details</h2> <div class="row"> <div class="column col-xs-12 col-sm-2 col-lg-4"> <label class="required" for="sell-title">Title</label> [select* your-title id:sell-title class:form-control "Mr" "Mrs" "Miss" "Ms"] </div> <div class="column col-first-name col-xs-12 col-sm-5 col-lg-4"> <label class="required" for="sell-first-name">First Name</label> [text* your-first-name id:sell-first-name class:form-control placeholder "Enter your first name"] </div> <div class="column col-last-name col-xs-12 col-sm-5 col-lg-4"> <label class="required" for="sell-last-name">Last Name</label> [text* your-last-name id:sell-last-name class:form-control placeholder "Enter your last name"] </div> <div class="column col-xs-12 col-sm-12 col-lg-4"> <label class="required" for="sell-email">Email Address</label> [email* your-email id:sell-email class:form-control placeholder "Enter your email address"] </div> <div class="column col-xs-12 col-sm-6 col-lg-4"> <label class="required" for="sell-daytime-phone">Daytime Telephone</label> [tel* your-daytime-phone id:sell-daytime-phone class:form-control placeholder "Enter your telephone number"] </div> <div class="column col-xs-12 col-sm-6 col-lg-4"> <label class="" for="sell-mobile-phone">Mobile Telephone</label> [tel your-mobile-phone id:sell-mobile-phone class:form-control placeholder "Enter your mobile number"] </div> <div class="column col-xs-12 col-sm-6 col-lg-6"> <label class="required" for="sell-address-1">Address Line 1</label> [text* your-address-1 id:sell-address-1 class:form-control placeholder "Enter your address"] </div> <div class="column col-xs-12 col-sm-6 col-lg-6"> <label class="" for="sell-address-2">Address Line 2</label> [text your-address-2 id:sell-address-2 class:form-control placeholder "Enter your address"] </div> <div class="column col-xs-12 col-sm-12 col-lg-4"> <label class="required" for="sell-city">Town/City</label> [text* your-city id:sell-city class:form-control placeholder "Enter your town/city"] </div> <div class="column col-xs-12 col-sm-6 col-lg-4"> <label class="required" for="sell-county">County</label> [text* your-county id:sell-county class:form-control placeholder "Enter your county"] </div> <div class="column col-xs-12 col-sm-6 col-lg-4"> <label class="required" for="sell-postcode">Postcode</label> [text* your-postcode id:sell-postcode class:form-control placeholder "Enter your postcode"] </div> <div class="column col-xs-12 col-sm-12 col-lg-6"> <label class="required" for="sell-method">Choose your method of payment</label> [select* your-method id:sell-method class:form-control "Instant Bank Transfer" "Cash" "Cheque"] </div> <div class="column col-xs-12 ccol-sm-12 col-lg-6"> <div class="input-label required">Terms & Conditions</div> [acceptance your-price-acceptance id:sell-price-acceptance]I accept the price offered above for my gold.[/acceptance] [acceptance your-terms-acceptance id:sell-terms-acceptance]I accept the <a href="/terms-conditions/" target="_blank">terms & conditions</a>.[/acceptance] [acceptance your-acknowledgement id:sell-acknowledgement]I declare and acknowledge that: 1. I confirm the property enclosed is mine to sell, 2. I believe the items(s) to be genuine gold or platinum 3. You will contact me if the value calculated upon receipt differs in weight or carat 4. I accept payment will only be made to the person named on the submission form.[/acceptance] </div> <div class="column col-submit col-xs-12 col-sm-12"> <div class="alert alert-info">After clicking the ‘Submit’ button below, we'll email you a form to print off and include with the package you send to us. If you wish to be paid by bank transfer, please write your bank details on the form once printed.</div> <div class="submit">[submit class:btn class:btn-gold "Submit"]</div> </div> </div> </div> </div>
<?php /** @var \Strive\Sections\Pdf_Form $this */ ?> <head> <style> h1, h2 { margin-top: 0; } th, td { text-align: left; vertical-align: top; } .section { padding: 20px 0; } .border-top { border-top: solid 1px #E7E7E7; } .cut-top { border-top: dashed 1px #E7E7E7; } .text-placeholder { background-color: #F7F7F7; } .cut-note { text-align: center; font-size: 80%; margin-bottom: 5px; } </style> </head> <body> <h1>Step 3. Print & post this form with your gold</h1> <div class="section quote border-top"> <h2 class="section-title">Customer Quote:</h2> <div> <?php if ( $this->calculator['empty'] 😞 ?> <p>You didn't weigh your gold - don't worry, we'll do it for you and call you with an offer. </p> <?php else: ?> <ol> <?php foreach ( $this->calculator['items'] as $item 😞 ?> <li><?php echo $item['weight']; ?>g of <?php echo $item['name']; ?> - £<?php echo $item['price']; ?></li> <?php endforeach; ?> </ol> <p>Total: £<?php echo $this->calculator['total']; ?></p> <?php endif; ?> </div> </div> <div class="section details border-top"> <h2 class="section-title">Customer Details:</h2> <table width="100%"> <tr> <td width="50%"> <table width="100%"> <tr> <th>Reference:</th> <td><?php echo $this->reference; ?></td> </tr> <tr> <th>Name:</th> <td></td><?php echo empty( $this->title ) ? '' : $this->title; ?> <?php echo empty( $this->first_name ) ? '' : $this->first_name; ?> <?php echo empty( $this->last_name ) ? '' : $this->last_name; ?></td> </tr> <tr> <th>Email:</th> <td><?php echo empty( $this->email ) ? '-' : $this->email; ?></td> </tr> <tr> <th>Telephone:</th> <td><?php echo empty( $this->daytime_phone ) ? '-' : $this->daytime_phone; ?></td> </tr> <tr> <th>Mobile:</th> <td><?php echo empty( $this->mobile_phone ) ? '-' : $this->mobile_phone; ?></td> </tr> </table> </td> <td width="50%"> <table width="100%"> <tr> <th>Address 1:</th> <td><?php echo empty( $this->address_1 ) ? '' : $this->address_1; ?></td> </tr> <tr> <th>Address 2:</th> <td><?php echo empty( $this->address_2 ) ? '' : $this->address_2; ?></td> </tr> <tr> <th>Town/City:</th> <td><?php echo empty( $this->city ) ? '' : $this->city; ?></td> </tr> <tr> <th>County:</th> <td><?php echo empty( $this->county ) ? '' : $this->county; ?></td> </tr> <tr> <th>Postcode:</th> <td><?php echo empty( $this->postcode ) ? '' : $this->postcode; ?></td> </tr> </table> </td> </tr> </table> </div> <div class="section payment border-top"> <p>Preferred Payment Method: <?php echo empty( $this->method ) ? '' : $this->method; ?></p> <?php if ( $this->method === 'Instant Bank Transfer' 😞 ?> <p>Write down your bank details below for the account in which you wish funds to be deposited.</p> <table width="100%"> <tr> <th width="25%">Bank:</th> <td width="75%" class="text-placeholder"> </td> </tr> <tr> <th>Name on Account:</th> <td width="75%" class="text-placeholder"> </td> </tr> <tr> <th>Sort Code:</th> <td width="75%" class="text-placeholder"> </td> </tr> <tr> <th>Account No:</th> <td width="75%" class="text-placeholder"> </td> </tr> </table> <?php endif; ?> </div> <div class="cut-note">Print this form, include the above part in your package and post to the address below.</div> <div class="section address cut-top"> <p> SMG<br><br> <?php echo empty( $this->send_address ) ? '' : $this->send_address ?> </p> </div> </body>
any help would be appreciated. Edited July 28 by Barandcode tags added Hey can anyone please help? I making this form on my website and I have two drop down lists, one is for sizes and the other is for colors. They both have an option for "other" and I'm wanting a textbox to appear when "other" is selected. I got the first drop down to work but I can't figure out how to get the second one to work without messing with the first. Here is the code I have please help: <form name="form1" method="post" action=""> <script type="text/javascript"> function showfield(name){ if(name=='Other')document.getElementById('div1').innerHTML='Other: <input type="text" name="other" />'; else document.getElementById('div1').innerHTML=''; } </script> <p>Size: <select name="size" id="size" onchange="showfield(this.options[this.selectedIndex].value)"> <option selected="selected">Please select ...</option> <option value="1' H X 6" W">2' H X 1' 6" W</option> <option value="1' H X 2' W">1' H X 2' W</option> <option value="1' H X 1' 4" W">1' H X 1' 4" W</option> <option value="Other">Other</option> </select> <div id="div1"></div> <p>Color: <select name="Color" id="Color" onchange="showfield(this.options[this.selectedIndex].value)"> <option selected="selected">Please select ...</option> <option value="Walnut Stain/Dark Brown">Walnut Stain/Dark Brown</option> <option value="Tan">Tan</option> <option value="Walnut">Walnut</option> <option value="Other">Other</option> </select> <div id="div1"></div> </p> I am currently creating a form and I want to populate a drop down selection menu with data from two fields in a form. For example, I want it to pull the first and last name fields from a database to populate names in a drop down menu in a form. I want the form to submit to the email address of the person selected in the drop down. Is this possible to do? The email is already a field in the record of the person in the database. Can anyone give me some pointers or advice on how I should go about setting up the "Select" box drop down? I am not sure how to code it to do what I am wanting. Any links to relevant help would be appreciated too. Thanks in advance! |