PHP - Hw Can I Get Drop Down Form To Change Sort By Form Asc Or Desc?
Hi i am trying to change the query to sort by desc or asc I am using the switch method but the form is not calling the switch statment can someone help me out please?
this is the swicth script Code: [Select] switch ($sortby) { case "ASC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'ASC', 'paged' => get_query_var('paged') ); break; case "DESC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'DESC', 'paged' => get_query_var('paged') ); break; }This is the form Code: [Select] <form name="myForm"> <select id="sortby" > <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select> </form> I intend to use a onchange so that when depending on the option they select it will change the order? Similar TutorialsHello and Gm. I have a script (below) which paginates a mysql table. Showing 4 rows per page. It works well. <?php $sql = mysql_query("SELECT * FROM tablename ORDER BY id ASC"); $nr = mysql_num_rows($sql); if (isset($_GET['pn'])) { $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); } else { $pn = 1; } $itemsPerPage = 8; //number of rows per page $lastPage = ceil($nr / $itemsPerPage); if ($pn < 1) { $pn = 1; } else if ($pn > $lastPage) { $pn = $lastPage; } $centerPages = ""; $sub1 = $pn - 1; $sub2 = $pn - 2; $add1 = $pn + 1; $add2 = $pn + 2; if ($pn == 1) { $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } else if ($pn == $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; } else if ($pn > 2 && $pn < ($lastPage - 1)) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> '; } else if ($pn > 1 && $pn < $lastPage) { $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> '; $centerPages .= ' <span class="pagNumActive">' . $pn . '</span> '; $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> '; } $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; $sql2 = mysql_query("SELECT * FROM tablename ORDER BY id ASC $limit"); //second query $paginationDisplay = ""; if ($lastPage != "1"){ $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. ' '; if ($pn != 1) { $previous = $pn - 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> '; } $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>'; if ($pn != $lastPage) { $nextPage = $pn + 1; $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> '; } } $outputList = ''; while($row = mysql_fetch_array($sql2)){ print "$row[permalink]"; print "$row[title]"; } ?> </div> <h2>Total Items: <?php echo $nr; ?></h2> <?php echo $paginationDisplay; ?> <?php print "$outputList"; ?> What I would like to do is have it like you see on other sites where there is a drop down menu that one can sort by a column first and it paginates after. So the url or dropdown would look something like /paginatedfile.php/column_name=title&orderby=desc And if you click page 2 you get a url like.. /paginatedfile.php/column_name=title&orderby=desc&pn=2 Can someone please help. Thanks, Chris Hey guys, I am having trouble figuring this out. I currently have a database that automatically sorts itself by the id of the data. But, I am wanting the user to be able to change the sort order via a select box. I already have the select box programmed with the options, but I am not sure how to go about coding the options to change the sort order of the displayed data. What would the best way to go about programming this be? Thank you very much ahead of time!! Hi all I have a filter system on a website I am creating and there are three forms each sends a value to the url using get. Every time a user selects the drop down on the first form it send to the url and then a SQL query is run to select items from a database which works great for all three forms. However, the problem I have is when the user goes and re-selects a category from the first form it needs to reset the other two below it and emptying the url parameter for both so it just asks the SQL to select the items from that category again. Please help Many thanks Pete Hi I am really getting with validating a drop down box in my form for posting I have set all the <options> in html form as followed: <form method="post" action="thankyou.php"> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> <select name="visitortitle"> <option>Please Select</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> </select> </form> now I'm trying to find a way to validate it in the .php sending side and using this: <?php $visitortitle = $_POST['visitortitle']; if (!isset($visitortitle)) { echo $visitortitle; } mail("email@domain.com", $subject, $message, $from); ?> I have tried so many different ways with - if (!isset - but cant get the send mail to recognise the drop down menu selection!!!! Any help would really be appreciated as I'm not that up on php coding. Thanks in advance. Gary Hey guys i am new around here and i need some help with php. So basically i want to make a submit form and i found a problem for myself here's some images to understand what i am talking about. so here's what i've made at first. This is meant for new data. <p><label>Status :</label> <select name="status" > <option value=""></option> <option value="Ongoing">Ongoing</option> <option value="Completed">Completed</option> </select> basically what I want is when I edit the data, that selection returns the value that was stored in the database rather than just null value. See image below to understand what i am trying to do. i dont really get how to do it with select. Please help me and thanks before. Sorry if my question was already asked before. Tried to search but didnt really found what i am looking for. Hello, i am trying to create a drop down list witch is inside a form and it is dynamicly created. When the user press the download button of the form to automaticly donwload a pdf.But i dont' kown how to do that. Here is the code This is the form. there us a download button. when it's clicked it goes to pdf.php posting the teuxos id to the pdf.php Code: [Select] <form id="form1" name="form1" method="post" action="pdf.php"> <label for="teuxos_drop_down"></label> <select name="teuxos" id="teuxos_drop_down"> <?php while($teuxoi_row = mysql_fetch_array($teuxoi_res)){ echo "<option value=".$teuxoi_row['teuxos_id'].">" .$teuxoi_row["teuxos"]. "</option>"; } ?> </select> <button> download</button> </form> and here what i have on pdf.php. Insead of downloading the file i have it empbedded. But i want to download automaticly when the user clicks the download button Code: [Select] if (isset($_POST['teuxos'])){ $teuxos_id = $_POST['teuxos']; }else{ $teuxos_id= NULL; } $teuxos_res = mysql_query("SELECT * FROM teuxoi WHERE teuxos_id=".$teuxos_id, $connection); if(!$teuxos_res){ die("Database Query Failed" . mysql_error()); } $teuxos_row = mysql_fetch_array($teuxos_res); ?> <?php echo "<embed src='".$teuxos_row['teuxos_link']."' width='1000' height='800'/>"; ?> Hello all,
I am new in php and would like to help me in in code.
I would like to implement a html form that will upload to my linux server some files, some info as well and will run a bash command.
To be more clear, users will:
Send to the linux server two files (I have done it).
Select from a drop down list a specific directory, and once this specific directory has been selected to activate one other drop down menu with its childs.
Send all those info to a bash script.
For case b, assume that we have the following structure
my_dir/cars/brand1
my_dir/cars/brand2
my_dir/cars/brand3
my_dir/motors/brand5
my_dir/motors/brand6
the first drop down list should list only cars and motors while the second only brand1, brand2, and brand3 if cars is selected or brand5 and brand6 if motors is selected.
For case c, once the form is submitted, I would like the command:
./script.sh –a uploadedfile1 –b uploadedfile2 –c dropdown1 –d dropdpwn2
Any help is appreciated.
Best,
Hi, I have this form currently setup and is showing the value from the table. <form action="updaterates.php" method="post"> <table width="350"> <tr> <td width="100">7 Nights</td> <td width="100"><input type="text" name="rates1" value="<?php echo ($row['rates1']); ?>" maxlength="3" size="3"></td> </tr> </table> </form> What do I need to do in order for it to update the value in the table... Thanks in advance... Hello everyone, I'm simply trying to move a character on a map. When the user selects a direction and a speed the character is moved on the map. Simple right? I've tried a few methods of doing this to no avail. I will list the different things I've tried. Code: [Select] <form action="index.php?do=move" method="post"> <select name="direction"> <option value="north" selected>North</option> <option value="south">South</option> <option value="east">East</option> <option value="west">West</option> </select> <select name="speed"> <option value="move0" selected>Feet +0</option> <option value="move1">Goat +1</option> <option value="move2">Donkey +2</option> <option value="move3">Cow +3</option> <option value="move4">Pig +4</option> <option value="move5">Horse +5</option> </select><br /> <input type="submit" name="post" value="Move"> </form> if (isset($_POST["post"])) { if (isset($_POST["direction"]) == "north") {$latitude++; if ($longitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move1")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move2")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move3")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move4")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move5")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "south") {$latitude--; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move1")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-2)) { $latitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move2")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-3)) { $latitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move3")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-4)) { $latitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move4")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-5)) { $latitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move5")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-6)) { $latitude = ($controlrow["gamesize"]*-6); } } elseif (isset($_POST["direction"]) == "east") {$longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move1")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*2)) { $longitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move2")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*3)) { $longitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move3")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*4)) { $longitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move4")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*5)) { $longitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move5")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*6)) { $longitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "west") {$longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move1")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-2)) { $longitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move2")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-3)) { $longitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move3")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-4)) { $longitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move4")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-5)) { $longitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move5")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-6)) { $longitude = ($controlrow["gamesize"]*-6); } } } Also if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move0")) { $latitude++; if ($latitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move1")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move2")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move3")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move4")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move5")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } } } } } } Any help would be appreciated. If you need more info just ask. Thanks, Waffles Hi
I'm totally green when it comes to php, but am learning it the hard way. Any help is appreciated.
I have a form the currenty uses a custom taxonomy but it has a text field, and I want it to call and list the taxonomy items with checkboxes so instead of entering words the visitor can just multiple check off the taxonomies that relate to them.
It's a job board, this is the job skill part that relates to their expertise.
There is a job category in the form, and I tried to use the syntax to get the taxonomy and implode it but
I really don't know what I'm doing.
See the "skills" item? I want to make that a bunch of checkboxes to allow selection the the pre defined resume_skills taxonomy.
http://outsourcing.j...it-resume-free/
Any help would be great, and I'm not sure what code I need to put in here.
Mark
Hi, I am using this code, what i want is to random fill up stepa field with either option a or option b every time i refresh the page, any help is highly appreciated!:
<form action="myc.php" method="get"> <label for="element_1"> </label> <div> <select class="element select medium" name="stepa"> <option value="" selected="selected"></option> <option value="option a" >Advanced Human option a</option> <option value="option b">Advanced Human Option b</option> </select> </div> <br> <input type="submit"> </form>
Ok here is what im trying to do: 1. drop down list pulled from mysql database.( working ) 2. after you select the name in the drop down list 3. Use selected name to another page. here is code Code: [Select] <?php include('include/db_connection.inc'); $table = "truck_master"; $result = mysql_query( "SELECT driver_name FROM $table" ); $options=""; while ($row=mysql_fetch_array($result)) { $driver_name=$row["driver_name"]; $options.="<OPTION VALUE=\"driver_name\">".$driver_name.'</option>'; } ?> <html> <head> </head> <body> <table align="center"> <form name="form1" method="GET" align="center" action="issue.php"> <tr> <td>Driver Name :</td> <td><SELECT name="driver_name"><OPTION VALUE=''>Choose<?php echo $options?></SELECT> </td> </tr> <tr> <td><input type="submit" name="Submit" value="Submit"> </td> </tr> </form> </table> </body> <html> Second Code IS Code: [Select] $driver = $_GET['driver_name']; Hi I'm new here, also I'm new in php. What I need to do is to write registration form with drop down menu. Actually, I need to have drop down menu which would write data into database when someone fill registration form. Also I need when someone choose one of the city name in drop down menu, to display certain image in specific php page. Can anyone help me. Here is my code for registration form : register.php <?PHP //Database Information $dbhost = ""; $dbname = ""; $dbuser = ""; $dbpass = ""; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $name = $_POST['name']; $email = $_POST['email']; $username = $_POST['username']; $password = md5($_POST['password']); $grad = $_POST['grad']; // lets check to see if the username already exists $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); $username_exist = mysql_num_rows($checkuser); if($username_exist > 0){ echo "I'm sorry but the username you specified has already been taken. Please pick another one."; unset($username); include 'register.html'; exit(); } $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); $email_exist = mysql_num_rows($checkemail); if($email_exist > 0){ echo "Email koji ste izabrali vec postoji."; unset($email); include 'register.html'; exit(); } $checkname = mysql_query("SELECT name FROM users WHERE name='$name'"); $name_exist = mysql_num_rows($checkname); if($name_exist > 0){ echo "Ime koje ste izabrali vec postoji."; unset($name); include 'register.html'; exit(); } // lf no errors present with the username // use a query to insert the data into the database. $query = "INSERT INTO users (name, email, username, password, grad) VALUES('$name', '$email', '$username', '$password','$grad')"; mysql_query($query) or die(mysql_error()); mysql_close(); if(empty($name) || empty($email) || empty($username)) { echo "Nisu uneseni svi podaci."; } /*else if(empty(($password))) //ovaj uslov ne prolazi !!! { echo "Niste uneli lozinku."; }*/ else { echo "Uspesno ste se registrovali"; } ?> and for form : register.html <form name="login" method="post" action="register.php"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#ff6600"> <p align="center"><font color="white"><span style="font-size:14pt;"><b>Registration</b></span></font></p> </td> </tr> <tr> <td width="555"> <table border="0" width="555" align="center"> <tr> <td width="116"><span style="font-size:12pt;">Name:</span></td> <td width="156"><input type="text" name="name" maxlength="100"></td> <td width="200"><p align="left"><span style="font-size:11pt;"><i>*Ukucajte vase puno ime i prezime*</i></span></p></td> </tr> <tr> <td width="116"><span style="font-size:12pt;">Email:</span></td> <td width="156"><input type="text" name="email" maxlength="100"></td><br/> </tr> <tr> <td width="116"><span style="font-size:12pt;">Username:</span></td> <td width="156"><input type="text" name="username"></td><br/> </tr> <tr> <td width="116"><span style="font-size:12pt;">Password:</span></td> <td width="156"><input type="password" name="password"></td><br/> </tr> <tr> <td width="116"> </td> <td width="156"> <p align="right"><input type="submit" name="submit" value="Submit"></p> </td> </tr> <tr> <td> <select name = "dropdown" value="options"> <option value "register.php">Izaberi grad</option> <option value = "Beograd">Beograd</option> <option value = "Nis">Nis</option> <option value = "Novi Sad">Novi Sad</option> </select> </td> </tr> </table> </td> </tr> <tr> <td width="219" bgcolor="#ff6600"> </td> </tr> </table> </form> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350095.0 Hi I have a form that is popluated from the database now I am trying to get the switch case to be based on the option the user selects is this possible to make a case a variable popluated by the drop down if so can someone show me what am i missing? the value I am trying to get from the form to the switch case is the ( $val->slug) but the value not been set help please here the form Code: [Select] <form method="post"> <select name="deal-locations" onChange="this.form.submit()"> <?php while(list($key,$val) = each($locations)) { ?><option value="<?php echo $val->slug; ?>"><?php echo $val->slug; ?></option><?php } ?> </select> <input type="submit" value="submit"> </form> Here the switch case Code: [Select] switch ($_POST['deal-locations']) { case " $val->slug": echo "<h3>deal-locations: ASC</h3>"; $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'deal-locations' => ' $val->slug', 'where' => ' $val->slug', 'paged' => 'paged' ); break; } Name says it all. I have a form and 2 tables that are going to have to be linked with each other. Although what I'm trying to do now is very basic and I'm struggling haha Though this is my first php project Basicly I got a form with a drop down menu, which I want to display the contents of my table (course) which the user then selects from and submits to another table (student) Here is my code for this part <?php Code: [Select] <?php $q = "SELECT cname FROM course "; $result = mysql_query($q); $course = mysql_fetch_array($result); ?> <div id="apdiv3"> <FORM action = "demo.php" method ="post"> <p>Course name:</p> <select name="cname"> <OPTION> <?php echo $course['cname']; ?> </option> </SELECT>?> It only displays 1 item from my course table. What am I doing wrong? And also please explain so I can learn from my mistakes 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> 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> GREAT this forum - JUST GREAT !... Issue: All data entered into my online form was lost (blanked out) and the form returned correctly with message "wrong verification code", when submitted with the wrong verification code. However, going through this great forum I managed to get all - manually entered - data back ! I placed value="<?php echo $_GET['the_field_name'];?>"/ after each input field. BUT... not so with input fields entered from drop-down menu ! How do I put a similar string for the field "Payment by" in this sample: <tr> <td class="table-inquire" width="47%"> <font face="Verdana" size="1" color="#000042"> Payment by:</font></td> <td class="table-inquire" width="51%" colspan="2"> <font color="#400000" face="Verdana"> <select name="payment" size="1"> <option value="VISA">VISA</option> <option value="MASTER">MASTER</option> <option value="CASH">CASH</option> <option value="T/T Banktransfer">T/T Banktransfer</option> <option selected>Please select</option> </select></font><font size="2" color="#400000" face="Verdana"></font></td> </tr> Any advise greatly appreciated. Thanks. As a complete newbie to php and webdesigning i have a following problem.I would like to retrieve the data from database and display it in a drop down menu.Then i should allow the user to select the values from drop down list along with other details,in other words i have to embed the drop down output as the form input for the user and store the form data in another table.I am running a xampp server and i am using php 5.4 version.Please help.My code is as follows.In this case project_name is displayed as the drop down output.but how do i use the same drop down output as a input in the form. <html> <head></head> <body> <?php error_reporting(E_ALL ^ E_DEPRECATED); include 'connect.php' ; $tbl_name="projects"; $sql="SELECT project_name FROM $tbl_name "; $result=mysql_query($sql); if($result === FALSE) { die(mysql_error()); } ?> <form name="resources" action="hourssubmit.php" method="post" > <?php echo "<select name='project_name'>"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['project_name'] ."'>" . $row['project_name'] ."</option>"; } echo "</select>"; ?> </form> </body> </html> |