PHP - Help Add A Drop List To <input Field Or Change This Code To A <select Option?
I have a search function in php where the text characters are matched to characters in a tables field--- works perfectly....
I need to make the input box have a droplist of words from database, this is also easy for me to do. the problem here is there is no definitive value! the options list always outputs a blank in the url--- its supposed to search a matching value and then output the matching value to url... Here is the droplist code: $output['RATESTITLE']='<input class="inputbox" type="text" size="24px" name="ratestitle" value="'.$sch->filter['ratestitle'].'" onfocus="if (this.value ==\''.$output['LANGUAGE_SEARCH_RATESTITLE'].'\') {this.value = \'\'}" />'; this outputs a input text box--- i want to have a droplist of options to populate this text box... If you must know this is the third day im at it... Similar TutorialsHello guys I've hit a problem whicle trying to validate my form. I have 3 drop down boxes where the user chooses from three options. But I can't seem to figure out how to set the validation so the user does not select the same option in each drop down. Can anyone help me solve this please. Thank you. <p><b>Course Choice 1</b> <select name="course1"> <option value="0"></option> <option value="Business computer Systems">Business computer Systems</option> <option value="Business computer Science">Business computer Science</option> <option value="Business computer Science (Games)">Business computer Science (Games)</option> <option value="Business Information Systems">Business Information Systems</option> <option value="Digital Media Development">Digital Media Development</option> <option value="Digital Media">Digital Media</option> </select></p> <p><b>Course Choice 2</b> <select name="course2"> <option value="Leave Blank">Leave Blank</option> <option value="Business computer Systems">Business computer Systems</option> <option value="Business computer Science">Business computer Science</option> <option value="Business computer Science (Games)">Business computer Science (Games)</option> <option value="Business Information Systems">Business Information Systems</option> <option value="Digital Media Development">Digital Media Development</option> <option value="Digital Media">Digital Media</option> </select></p> <p><b>Course Choice 3</b> <select name="course3"> <option value="Leave Blank">Leave Blank</option> <option value="Business computer Systems">Business computer Systems</option> <option value="Business computer Science">Business computer Science</option> <option value="Business computer Science (Games)">Business computer Science (Games)</option> <option value="Business Information Systems">Business Information Systems</option> <option value="Digital Media Development">Digital Media Development</option> <option value="Digital Media">Digital Media</option> </select></p> <div align="centre"><input type="submit" name="submit" value="send request" /></div> //Validate course choice 1 if (!empty($_REQUEST['course1'])) { $course1 = $_REQUEST['course1']; } else { $course1 = NULL; echo '<p><font color="red">Please enter your first choice</font></p>'; } //Validate course choice 2 if (!empty($_REQUEST['course2'])) { $course2 = $_REQUEST['course2']; } else { $course2 = NULL; echo '<p><font color="red">Please enter your second choice</font></p>'; } //Validate course choice 3 if (!empty($_REQUEST['course3'])) { $course3 = $_REQUEST['course3']; } else { $course3 = NULL; echo '<p><font color="red">Please enter your third choice</font></p>'; } //If everything is ok, print the message if ($name && $email && $course1 && $course2 && $course3) { echo "<p>Thank you, <b>$name</b>, You have chosen the following courses for information:<br /><br /> <b>$course1</b><br /> <b>$course2</b><br /> <b>$course3</b></p> <p>We will reply to you at <i>$email</i>.</p>\n"; } else { // One form element was not filled out properly echo '<p><font color="red">Please go back and fill out the form again.</font></p>'; } Hi, I am trying to create a drop down menu that will select a value that is stored in the database - right now the code creats a dropdown (with nothing selected) - hope someone can help. in the database, the values are stored as --null- Option1 Option2 Option3 my code is Code: [Select] $instruction = $_GET['instruction']; <?php <select id="instruction" name="instruction"> <option value="" <?php if (!empty($instruction) && $instruction == '' ) echo 'selected = "selected"'; ?>></option> <option value="Option1" <?php if (!empty($instruction) && $instruction == 'Option1') echo 'selected = "selected"'; ?>>Option1</option> <option value="Option2" <?php if (!empty($instruction) && $instruction == 'Option2') echo 'selected = "selected"'; ?>>Option2</option> <option value="Option3" <?php if (!empty($instruction) && $instruction == 'Option3') echo 'selected = "selected"'; ?>>Option3</option> </select> <? Hi, I'm a php newbie, with some mysql experience. I have a mysql database as follows: Database=watch, Table=events - fields id, reportno, sdate, comments What I need is: 1. A dropdown list to display reportno from mysql database. 2. Depending on which reportno I choose, I'd like to open a popup(or separate) page to display the stored information. Tks in advance for any help Hi guys, basically here pull out the data from database then creating taxt field automatically and submit into anther table. everything works fine but data not inserting in to the table. could you guys check my code please? <?php $con = mysql_connect("localhost","root",""); mysql_select_db("uni", $con)or trigger_error('MySQL error: ' . mysql_error()); ?> <?php $result = mysql_query("SELECT * FROM course") or trigger_error('MySQL error: ' . mysql_error()); echo '<select name ="cid[]">'; while($row = mysql_fetch_array($result)) { echo '<option value="' . $row['CourseID'] . '">'. $row['CourseID'] .'</option>'; } echo '</select>'; //------------------ ?> <?php if(!empty($_POST["submit"])) { $value = empty($_POST['question']) ? 0 : $_POST['question']; ?> <form name="form1" method="post" action="result.php"> <?php for($i=0;$i<$value;$i++) { echo 'Question NO: <input type="text" name="qno[]" size="2" maxlength="2" class="style10"> Enter Marks: <input type="text" name="marks[]" size="3" maxlength="3" class="style10"><br>'; } ?> <label> <br /> <br /> <input type="submit" name="Submit" value="Submit" class="style10"> </label> </form> <?php } else{ ?> <form method="POST" action="#"> <label> <span class="style10">Enter the Number of Question</span> <input name="question" type="text" class="style10" size="2" maxlength="2"> </label> <input name="submit" type="submit" class="style10" value="Submit"> </form> <?php }?> result.php <?php $con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error()); mysql_select_db("uni",$con) or die('Could not connect: ' . mysql_error()); foreach ($_POST['cid'] as $c) {$cid [] = $c;} foreach($_POST['qno'] as $q){$qno[] = $q;} foreach($_POST['marks'] as $m){$marks[] = $m;} $ct = 0; for($i=0;$i<count($qno);$i++) { $sql="INSERT INTO examquesion (CourseID,QuesionNo,MarksAllocated) VALUES('$cid[$i]','$qno[$i]','$marks[$i]')"; mysql_query($sql,$con) or die('Error: ' . mysql_error()); $ct++; } echo "$ct record(s) added"; mysql_close($con) ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316053.0 Howdy everyone, please i need help changing a php coded form from a checkbox to a select menu. Here's the form. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" > <table class="dtable2"> <tr><th colspan="5">Enter a domain name:</th></tr> <tr><td colspan="5"><center>www.<input name="domain" type="text" size="35" /></center></td></tr> <tr><th colspan="5">Select an extension:</th></tr> <tr> <?php $i = 0; foreach ($this->serverList as $value) { if ($value['check'] == true) $checked=" checked "; else $checked = " "; echo '<td><input type="checkbox" name="top_'.$value['top'].'"'.$checked.'/>.'.$value['top'].'</td>'; $i++; if ($i > 4) { $i = 0; echo '</tr><tr>'; } } ?> </tr> </table> <center><input type="submit" name="submitBtn" class="sbtn" value="Check" /></center> </form> <?php I'll really appreciate your help. Hello, I'm not able to figure how to fix these warnings / errors I'm getting. The file that I'm creating comes out correctly so it's as if I need some type of conditional to end the function calls or something? I'm really stumped with this one... Code: [Select] Undefined index: 1 Invalid argument supplied for foreach() Undefined index: 4 Invalid argument supplied for foreach() Undefined index: 7 Invalid argument supplied for foreach() Undefined index: 21 Invalid argument supplied for foreach() Undefined index: 2 Invalid argument supplied for foreach() Undefined index: 11 Invalid argument supplied for foreach() Undefined index: 6 Invalid argument supplied for foreach() Undefined index: 22 Invalid argument supplied for foreach() Undefined index: 24 Invalid argument supplied for foreach() Here is a var_dump of $menu Code: [Select] array(2) { ["items"]=> array(12) { [1]=> object(stdClass)#17 (10) { ["id"]=> string(1) "1" ["name"]=> string(4) "HOME" ["parent"]=> string(1) "0" ["type"]=> string(9) "slideshow" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [5]=> object(stdClass)#18 (10) { ["id"]=> string(1) "5" ["name"]=> string(4) "INFO" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [3]=> object(stdClass)#19 (10) { ["id"]=> string(1) "3" ["name"]=> string(9) "GALLERIES" ["parent"]=> string(1) "0" ["type"]=> string(6) "parent" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [18]=> object(stdClass)#20 (10) { ["id"]=> string(2) "18" ["name"]=> string(16) "GALLERY SECTIONS" ["parent"]=> string(1) "0" ["type"]=> string(14) "gallery_portal" ["order"]=> string(1) "4" ["visible"]=> string(4) "true" ["image"]=> string(11) "DSC0250.jpg" ["color"]=> string(6) "848a5a" ["link"]=> NULL ["target"]=> NULL } [22]=> object(stdClass)#21 (10) { ["id"]=> string(2) "22" ["name"]=> string(7) "CONTACT" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "5" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [24]=> object(stdClass)#22 (10) { ["id"]=> string(2) "24" ["name"]=> string(12) "MAILING LIST" ["parent"]=> string(1) "0" ["type"]=> string(5) "forms" ["order"]=> string(1) "6" ["visible"]=> string(5) "false" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [2]=> object(stdClass)#23 (10) { ["id"]=> string(1) "2" ["name"]=> string(7) "WEDDING" ["parent"]=> string(1) "3" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [4]=> object(stdClass)#24 (10) { ["id"]=> string(1) "4" ["name"]=> string(8) "ABOUT US" ["parent"]=> string(1) "5" ["type"]=> string(9) "text_page" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [7]=> object(stdClass)#25 (10) { ["id"]=> string(1) "7" ["name"]=> string(8) "CALENDAR" ["parent"]=> string(1) "5" ["type"]=> string(8) "calendar" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [21]=> object(stdClass)#26 (10) { ["id"]=> string(2) "21" ["name"]=> string(14) "PORTFOLIOSITEZ" ["parent"]=> string(1) "5" ["type"]=> string(8) "external" ["order"]=> string(1) "3" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> string(25) "http://portfoliositez.com" ["target"]=> string(6) "_blank" } [11]=> object(stdClass)#27 (10) { ["id"]=> string(2) "11" ["name"]=> string(9) "LANDSCAPE" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "1" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } [6]=> object(stdClass)#28 (10) { ["id"]=> string(1) "6" ["name"]=> string(9) "PORTRAITS" ["parent"]=> string(2) "18" ["type"]=> string(7) "gallery" ["order"]=> string(1) "2" ["visible"]=> string(4) "true" ["image"]=> NULL ["color"]=> NULL ["link"]=> NULL ["target"]=> NULL } } ["parents"]=> array(4) { [0]=> array(6) { [0]=> string(1) "1" [1]=> string(1) "5" [2]=> string(1) "3" [3]=> string(2) "18" [4]=> string(2) "22" [5]=> string(2) "24" } [3]=> array(1) { [0]=> string(1) "2" } [5]=> array(3) { [0]=> string(1) "4" [1]=> string(1) "7" [2]=> string(2) "21" } [18]=> array(2) { [0]=> string(2) "11" [1]=> string(1) "6" } } } And here is the code Code: [Select] public function sitemap() { $query = $this->db->order_by('parent', 'asc')->order_by('order', 'asc')->get('menu'); foreach($query->result() as $row) { $menu['items'][$row->id] = $row; $menu['parents'][$row->parent][] = $row->id; } function build_map($parent, $menu, &$data) { foreach($menu['parents'][$parent] as $itemId) { if(!isset($menu['parents'][$itemId])) { if(($menu['items'][$itemId]->parent == 0) && ($menu['items'][$itemId]->visible != 'false')) { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } elseif($menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type !='external' && $menu['items'][$itemId]->type != 'parent') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $name2 = str_replace(' ','-', $menu['items'][$menu['items'][$itemId]->parent]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name2 ."/" . $name ."</loc></url>\n"; } } if(isset($menu['parents'][$itemId]) && $menu['items'][$itemId]->visible != 'false' && $menu['items'][$itemId]->type != 'parent' && $menu['items'][$itemId]->type !='external') { $name = str_replace(' ','-', $menu['items'][$itemId]->name); $data .= "\t<url><loc>" . base_url() . "#!/". $name ."</loc></url>\n"; } build_map($itemId, $menu, $data); } } $data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n\t<url><loc>".base_url()."</loc></url>\n"; build_map(0, $menu, $data); $data .= "</urlset>"; write_file('sitemap.xml', $data); } Hello all , here is another problem of my project. I need to create a textarea , drop down list and submit button . At first , I can type whatever I want in the textarea , but for certain part I can just choose the word I want from drop down list and click submit , then the word will appear in the textarea as my next word . But I have no idea how to make this works , is there any simple example for this function ? Thanks for any help provided . Hi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin?? echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; Hi, In my mysql database i have a text input option, in the registration form and edit my details form i have a multiple select dropdown list, which user selects options to populate the text input box, which ultimately populates the text field in the mysql database. All works perfectly. The dropdownlist consists of 3 parts <optgroups> first is current selection (what is the usesr current selection)works fine, The second <optgroup> is existing words, what words we(the site) have given as options, and the third <optgroup> is the words that others have used. This is where im having a small problem. Because its a text field when i call the data from the database, it calls the entire text box as a single option in my select list.. I want to break the words in the text field (at the comma) and have them listed each one as an option in the select list. Example what i need: Words in text box:(my input allows the "comma") word1, word2, word3, word4, word5, word6, How i want them called/displayed: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> here's my code: $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $original_functionsexperience =doSelectSql($query,1); $query = "SELECT allwords FROM #__functions_experience WHERE profile_id = '".(int)$profileId."' LIMIT 1"; $functionsexperiencelist=doSelectSql($query); $funcexpList ="<select multiple=\"multiple\" onchange=\"setFunctionsexperience(this.options)\">"; foreach ($functionsexperiencelist as $functionsexperienceal) { $selected=""; if ($functionsexperienceals->allwords == $original_functionsexperience) $selected=' selected="selected"'; $allwords=$functionsexperienceal->allwords; $funcexpList .= "<optgroup label=\"Current selection\"> <option value=\"".$allwords."\" ".$selected." >".$allwords."</option> </optgroup> <optgroup label=\"Existing Words\"> <option value=\"existing1,\">existing1</option> <option value=\"existing2,\">existing2</option> <option value=\"existing3,\">existing3</option> <option value=\"existing4,\">existing4</option> <option value=\"existing5,\">existing5</option> <option value=\"existing6,\">existing6</option> </optgroup> <optgroup label=\"Others added\"> //heres problem <option value=\"".$allwordsgeneral."\">".$allwordsgeneral."</option> </optgroup>"; } $funcexpList.="</select>"; $output['FUNCEXPLIST']=$funcexpList; The result im getting for optgroup others added: word1, word2, word3, word4, word5, how can i get it like this: <option value=\"word1\">word1</option> <option value=\"word2\">word2</option> <option value=\"word3\">word3</option> <option value=\"word4\">word4</option> <option value=\"word5\">word5</option> <option value=\"word6\">word6</option> I am adding to a shopping cart using sessions, when I add a product with a selected size it echoes the correct size as text but when applying it to my option boxes as selected, it just shows the last item in the select box. here is the code for the session variables <?php for ($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket_counter++) { $price=sprintf("%01.2f",$ses_basket_price[$basket_counter]); $quantity=$ses_basket_amount[$basket_counter]; $code=$ses_basket_stockcode[$basket_counter]; $itemID=$ses_basket_id[$basket_counter]; $name=$ses_basket_name[$basket_counter]; $image=$ses_basket_image[$basket_counter]; $size=$ses_basket_size[$basket_counter]; $sizechoice=$ses_basket_sizechoice[$basket_counter]; // create array from sizes and make the option box selections if ($sizechoice!="" && (!in_array($sizechoice, array('One Size', 'one size', 'free size', 'Free Size', 'Adjustable', 'adjustable')))) { // add size trigger $sizelist="add"; //create the array $sizepick=explode(",", $sizechoice); } else { $sizepick=$sizechoice; } // adjust gst for AU customers if ($country='AU') { $price=sprintf("%01.2f",($price*1.1)); $unit=sprintf("%01.2f",($price/$quantity)); } else { $unit=sprintf("%01.2f",($price/$quantity)); } ?> and this bit inside the same loop displayes the select box for size <?php if ($sizelist && $sizelist='add') { echo "<select name='size' id='size' style='vertical-align:middle;'>"; foreach($sizepick AS $sizes) { if ($sizes==$size) { echo "<option value='$size' selected='selected'>$size</option>"; } else { echo "<option value='$sizes'>$sizes</option>"; }} echo "</select>"; } else { echo $size; } ?> appreciate any help on this ok so below is the select option for my form i creatig should this select have the name 0f bday form of the three selects so that when i put it into a variable it could just be $birthday = $_POST = ['bday']; Code: [Select] <select class="drop" name="bday"> <option>Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select class="drop" name="bday"> <option>Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select class="drop" name="bday"> <option>Year</option> <option value="2011">2011</option> <option value="2010">2010</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> i have a basic html form with a drop down selection box with 2 options ('old' and 'new'). when you click one it swaps them round to you can click the other because it is an onchange event. <form action="<?php $_SERVER['self']; ?>" method="get"> <select name="Time" onchange="this.form.submit();"> <option value="New">New</option> <option value="Old">Old</option> </select></form> I'm trying to pass php select option value to another page through url.but it's not working.please help me.
member.php
<?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("nordfxlk_member")or die(mysql_error()); $result = mysql_query("SELECT id,ugroup FROM ugroups"); ?> <select name='group' id='group' > <?php while ($line = mysql_fetch_array($result)) { echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>'; }?> </select> <a href="db_sql/add_group.php?ugroup=<?php echo $line['ugroup'] ;?>"> click</a>add_group.php include('../limoconfig.php'); if(!isset($_SESSION['adminuserid']) ) { header('Location:../index.php'); } else { $ugroup = $_GET['ugroup']; /*$id = $_GET['id'];*/ $acc_status = "update users set ugroup='".$ugroup."' where id=1931"; echo $acc_status; $rate = db::getInstance()->exec($acc_status); header('Location:../test.php'); } } i have this select box in a form Code: [Select] <select name='theoptions' style='color: #000000;text-align:center;background-color:#DEDEDE;border: 1px solid #D99C29;width:163px;padding:5px;' onchange='optionChanged(this);ChgBox(this.value);'> <option value='1' >Your comment on</option> <option value='3' >Your question on</option> <option value='4' >Your expertise on</option> <option value='2' >Your image about</option> <option value='5' >Your website about</option> <option value='0' >Comparison</option> </select> on the page where the form directs to i have Code: [Select] $options = $_POST['theoptions']; I want to get option 5 specificially, how do i do that? I've been using an option that's a state, an example would be South Carolina or North Dekota. In the url the $_GET var turns it into South+Carolina or North+Dekota. Is this common and okay across different Browsers? I've tried ie and firefox and the + sign is addded but I was wondering if they're just designed to be as idiot proof as possible. Thanks Hello, guys! Just a small first ever thread, where I ask a question where I hope anyone is able to help me out I am working on a project with a friend of mine for a company. I have a problem with the function on a form. I wonder; How do i change the option value of a form? Let's say if I choose a category like "Cake", I want the second drop down box to display different brands of cake. But if I choose bicycle for example, I want the option values to be different brands of bicycles. I hope you guys understand what I was trying to say here. Anyways, here is a sample image where I want this function to occur: Sample: Cheers and thanks in advance, Marius Hi.. I need to add code to check if the compound that was choose is reach the maximum value then if it is already reach theirs a notification displayed that he already gain the maximum. the problem is..I don't know how can I check if what the user choose before run the condition. here is my code: Code: [Select] <?php $config['BASE_DIR'] = dirname(dirname(__FILE__)); $config['BASE_DIR'] = $config['BASE_DIR']. '\MES PROJECT'; define('SMARTY_DIR', $config['BASE_DIR']. '/INCLUDE/smarty/libs/'); require(SMARTY_DIR . 'Smarty.class.php'); $smarty = new Smarty(); $smarty = new Smarty(); $smarty->template_dir = $config['BASE_DIR']. '/smarty/templates'; $smarty->config_dir = $config['BASE_DIR']. '/smarty/config'; $smarty->cache_dir = $config['BASE_DIR']. '/INCLUDE/smarty/cache'; $smarty->compile_dir = $config['BASE_DIR']. '/INCLUDE/smarty/templates_c'; // ================================================================================================================= $con= mysql_connect('localhost', 'root', ''); if (!$con) { echo 'failed'; die(); } mysql_select_db("mes", $con); $hostAddr = $_SERVER['REMOTE_ADDR']; $terminal = $hostAddr; //<-enable this in server //$terminal = $_POST['doThis']; //<- disable this in server $terminal = "192.168.1.101"; switch ($terminal) { case "192.168.1.101" : //<< enable this in server //case "1" : $smarty->assign('process', 'Rubber/Chemical Preparation'); $smarty->assign('termNo', 'Terminal 1'); $smarty->assign('text_name1','Compound Code'); $smarty->assign('text_name2','Lot Traveler ID'); $smarty->assign('text_name3','Kit Weight '); $smarty->assign('text_name4','Operator Code'); [b] $smarty->assign('compoundIndexValue', array('0', 'P28', 'P30', 'P32', 'P33', 'P35', 'P35M', 'P38', 'P40', 'P41', 'P42', 'P43', 'P46', 'P47', 'PXX', 'P35W'));[/b] $smarty->assign('names', array('<Choose Code>', 'P28', 'P30', 'P32', 'P33', 'P35', 'P35M', 'P38', 'P40', 'P41', 'P42', 'P43', 'P46', 'P47', 'PXX', 'P35W')); $smarty->assign('weightIndexValue', array('0', '60.145', '68.980', '65.381', '69.270', '49.360', '68.610', '54.880', '73.300', '51.973', '52.944', '57.627', '45.997', '69.196', '70.000', '55.000')); $smarty->assign('kitWeight', array('<Choose Weight>','60.145', '68.980', '65.381', '69.270', '49.360', '68.610', '54.880', '73.300', '51.973', '52.944', '57.627', '45.997', '69.196', '70.000', '55.000')); //Chemical weighing Process : Terminal 1 $smarty->display('header.tpl'); // common Header $smarty->display('box_1.tpl'); $smarty->display('footer.tpl'); [b] $compound = mysql_real_escape_string($_POST['compoundIndexValue']); $sql = "SELECT P28, P28_max, P28_min, P30, P30_max, P30_min, P32, P32_max, P32_min, P33, P33_max, P33_min, P35, P35_max, P35_min, P35M, P35M_max, P35M_min, P35W, P35W_max, P35W_min, P38, P38_max, P38_min, P41, P41_max, P41_min, P42, P42_max, P42_min, P43, P43_max, P43_min, P46, P46_max, P46_min, P47, P47_max, P47_min FROM parameter_settings"; $res_pcode = mysql_query($sql, $con); $row = mysql_fetch_assoc($res_pcode); $P28 = $row['P28']; $P28_max = $row['P28_max']; $P28_min = $row['P28_min']; $P30 = $row['P30']; $P30_max = $row['P30_max']; $P30_min = $row['P30_min']; $P32 = $row['P32']; $P32_max = $row['P32_max']; $P32_min = $row['P32_min']; $P33 = $row['P33']; $P33_max = $row['P33_max']; $P33_min = $row['P33_min']; $P35 = $row['P35']; $P35_max = $row['P35_max']; $P35_min = $row['P35_min']; $P35M = $row['P35M']; $P35M_max = $row['P35M_max']; $P35M_min = $row['P35M_min']; $P35W = $row['P35W']; $P35W_max = $row['P35W_max']; $P35W_min = $row['P35W_min']; $P38 = $row['P38']; $P38_max = $row['P38_max']; $P38_min = $row['P38_min']; $P41 = $row['P41']; $P41_max = $row['P41_max']; $P41_min = $row['P41_min']; $P42 = $row['P42']; $P42_max = $row['P42_max']; $P42_min = $row['P42_min']; $P43 = $row['P43']; $P43_max = $row['P43_max']; $P43_min = $row['P43_min']; $P46 = $row['P46']; $P46_max = $row['P46_max']; $P46_min = $row['P46_min']; $P47 = $row['P47']; $P47_max = $row['P47_max']; $P47_min = $row['P47_min']; $sql = "SELECT PCODE, total FROM kanban_checker WHERE PCODE = '$compound' ORDER BY PCODE"; $res_kanban = mysql_query($sql, $con); $row_kanban = mysql_fetch_assoc($res_kanban); $PCODE = $row_kanban['PCODE']; $total = $row_kanban['total']; if($compound == $P28 && $total == $P28_max){ echo "<script type='text/javascript'>notify(P28 gain total maximum)</script>"; } else { echo ''; } if($compound == $P30 && $total == $P30_max){ echo "<script type='text/javascript'>notify(P30 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P32 && $total == $P32_max){ echo "<script type='text/javascript'>notify(P32 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P33 && $total == $P33_max){ echo "<script type='text/javascript'>notify(P33 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P35 && $total == $P35_max){ echo "<script type='text/javascript'>notify(P35 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P35M && $total == $P35M_max){ echo "<script type='text/javascript'>notify(P35M gain total maximum)</script>"; } else{ echo ''; } if($compound == $P35W && $total == $P35W_max){ echo "<script type='text/javascript'>notify(P35W gain total maximum)</script>"; } else{ echo ''; } if($compound == $P38 && $total == $P38_max){ echo "<script type='text/javascript'>notify(P38 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P41 && $total == $P41_max){ echo "<script type='text/javascript'>notify(P41 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P42 && $total == $P42_max){ echo "<script type='text/javascript'>notify(P42 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P43 && $total == $P43_max){ echo "<script type='text/javascript'>notify(P43 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P46 && $total == $P46_max){ echo "<script type='text/javascript'>notify(P46 gain total maximum)</script>"; } else{ echo ''; } if($compound == $P47 && $total == $P47_max){ echo "<script type='text/javascript'>notify(P47 gain total maximum)</script>"; } else{ echo ''; }[/b] break; case "192.168.1.102" : //<< enable this in server //case "2" : $smarty->assign('process', 'Compounding Process'); $smarty->assign('termNo', 'Terminal 2'); $smarty->assign('text_name1','Lot Traveler ID'); $smarty->assign('text_name2','Kit Weight'); $smarty->assign('text_name3','Machine Code'); $smarty->assign('text_name4','Operator Code'); $smarty->assign('machineID', array('0', 'B1', 'B2', 'B3', 'K1', 'K2', 'OM1', 'OM2', 'OM3', 'OM4', 'OM5', 'OM6', 'OM7')); $smarty->assign('machineIDdisplay', array('<Choose Machine ID>', 'B1', 'B2', 'B3', 'K1', 'K2', 'OM1', 'OM2', 'OM3', 'OM4', 'OM5', 'OM6', 'OM7')); $smarty->display('header.tpl'); // common Header $smarty->display('box_2.tpl'); $smarty->display('footer.tpl'); break; case "192.168.1.103" : //<< enable this in server //case "3" : $smarty->assign('process', 'Extrusion Process'); $smarty->assign('termNo', 'Terminal 3'); $smarty->assign('text_name1','Lot Traveler ID'); $smarty->assign('text_name2','Kit Weight'); $smarty->assign('text_name3','Machine Code'); $smarty->assign('text_name4','Operator Code'); $smarty->assign('machineID', array('0', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6')); $smarty->assign('machineIDdisplay', array('<Choose Machine ID>', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6')); $smarty->display('header.tpl'); // common Header $smarty->display('box_2.tpl'); $smarty->display('footer.tpl'); break; case "192.168.1.104" : //<< enable this in server //case "4" : $smarty->assign('process', 'Half Shell Forming'); $smarty->assign('termNo', 'Terminal 4'); $smarty->assign('text_name1','Lot Traveler ID'); $smarty->assign('text_nameDG','New Lot ID'); $smarty->assign('text_name2','Machine ID'); $smarty->assign('text_name3','Output Qty.'); $smarty->assign('text_name4','Reject Qty.'); $smarty->assign('text_name5','Operator Code'); $smarty->assign('id', array('0', 'NTG1', 'NTG2', 'NTG3', 'NTG4', 'GTG1', 'SQG1', 'PL1')); $smarty->assign('id_name', array('<Choose Machine ID>', 'NTG1', 'NTG2', 'NTG3', 'NTG4', 'GTG1', 'SQG1', 'PL1')); $smarty->display('header.tpl'); // common Header $smarty->display('box_3.tpl'); $smarty->display('footer.tpl'); break; case "192.168.1.105" : //<< enable this in server //case "5" : $smarty->assign('process', 'Half Shell Deflashing'); //= to be implemented $smarty->assign('termNo', 'Terminal 5'); $smarty->assign('text_name1','Lot Traveler ID'); $smarty->assign('text_name2','Machine ID'); $smarty->assign('text_name3','Output Qty.'); $smarty->assign('text_name4','Reject Qty.'); $smarty->assign('text_name5','Operator Code'); $smarty->assign('id', array('0', 'US DEF.1', 'US DEF.2', 'FRENCH DEF.1', 'FRENCH DEF.2', 'THAILAND DEF.1', 'THAILAND DEF.2', 'HANAU 45 DEF.')); $smarty->assign('id_name', array('<Choose Machine ID>', 'US DEF.1', 'US DEF.2', 'FRENCH DEF.1', 'FRENCH DEF.2', 'THAILAND DEF.1', 'THAILAND DEF.2', 'HANAU 45 DEF.')); $smarty->display('header.tpl'); // common Header $smarty->display('box_3.tpl'); $smarty->display('footer.tpl'); break; } ?> My only purpose is to avoid adding data so i need to prompt if he already reach the maximum per compound. Thank you so much OK so I'm having a pull my hair out moment. I have spent all day trying to figure this out. I have a select box for a list of customers where one customer is unique and I want that account to appear twice in the list. That part was easy and when selected the appropriate info populates the page. The problem I am having is that no matter which one of those two options I click it only selects the second option . So in other words if these are the two options in the list: Some Business Week 1 Some Business Week 2 when I click either, Some Business Week 2 is always the one selected even though the page populates correctly. Any thoughts on what I need to change? Code: [Select] <?php do { mysql_select_db($database_customers, $customers); $query_multiple = "SELECT accnt, week, alt FROM schedule WHERE accnt = " . $customer['accnt']; $multiple_sel = mysql_query($query_multiple, $customers) or die(mysql_error()); $multiple = mysql_fetch_assoc($multiple_sel); $multiple_run = $multiple['alt']; if($multiple_run > 1) { for ($i = 1; $i <= $multiple_run; $i++) { mysql_select_db($database_customers, $customers); $query_get_week = "SELECT week, alt FROM schedule WHERE accnt = " . $customer['accnt'] . " AND alt = " . $i; $get_week_sel = mysql_query($query_get_week, $customers) or die(mysql_error()); $get_week = mysql_fetch_assoc($get_week_sel); $version1 = $inv_title . " Week " . $get_week['week']; $version2 = $customer['name'] . " Week " . $get_week['week']; ?> <option value="report.php?accnt=<?php echo $customer['accnt']; ?>&alt=<?php echo $get_week['alt'];?>"<?php if (!(strcmp($version1, $version2))) {echo "selected=\"selected\"";} ?>><?php echo $version2; ?></option> <?php } } else { $version1 = $inv_title; $version2 = $customer['name']; ?> <option value="report.php?accnt=<?php echo $customer['accnt']; ?>&alt=<?php echo $multiple['alt'];?>"<?php if (!(strcmp($version1, $version2))) {echo "selected=\"selected\"";} ?>><?php echo $version2; ?></option> <?php } ?> <?php } while ($customer = mysql_fetch_assoc($customer_sel)); ?> Hey guys, i have a small problemo. As you can see i have made an option list from 0 to 3. How can I put this optionlist in a for loop so I can save some place? I have found an example but I dont know how to integrate it in my php Example Code: [Select] for( $i = 0; $i < 4; $i++ ) { $optionlist .= "<option value=\"$i\">$i</option>\n"; } $optionlist .= "</select>\n"; Code: [Select] <?php $dranken = array("cola", "fanta", "bier", "koffie", "thee"); $prijzen = array("2", "2", "1.80", "2.20", "2.20"); $i = 0; echo "<table>"; while ($dranken[$i]) { $listnaam = $dranken[$i] . "_aantal"; $optionlist = "<select name= '$listnaam'><option>0</option><option>1</option><option>2</option><option>3</option></select>"; echo "<tr><td >" . $dranken[$i] . "</td>"; echo "<td>" . $prijzen[$i] . "</td>"; echo "<td>" . $optionlist . "</td></tr>"; $i++; } echo "</table>"; ?> thanks |