PHP - Check If Dropdown Option Matches And Select
Hi,
I am doing an EDIT user page and would like to check records with a dropdown and then set as selected, please help! <select name="BrokerID" class="small-input"> <option value="Please select an option">Please select a Broker</option> <?php while($row2 = mysql_fetch_array($broker)) { echo '<option name="BrokerID" value="'.$row2['BrokerID'].'">'.$row2['BrokerName'].'</option>'; } ?> </select> Similar TutorialsHi, 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 Hello, I am trying to get this backlink checker to work i have it working so it checks that the link itself matches and is there but this is the harder part that I don't understand. I want to have it also check the nodeValue to make sure that it matches one of the nodeValue's from a mysql table this is the code I have to make it check the href link Code: [Select] function CheckForTargetUrl($links, $target) { foreach ($links as $link) { if (strpos($link, $target) !== false) { return true; } } return false; } function ExtractHrefLinks($html) { $dom = new DOMDocument; $linkUrls = array(); @$dom->loadHTML($html); $links = $dom->getElementsByTagName('a'); foreach ($links as $link){ $linkUrls[] = $link->getAttribute('href'); } return $linkUrls; } function backlink_check($contenturl){ $url = 'businessinvestingsource.com'; $source = $contenturl; $falseFound = false; $html = file_get_contents ( $source ); $links = ExtractHrefLinks($html); if (CheckForTargetUrl($links, $url) === false) { $falseFound = "true"; $reportArray[$source] = 0; } else { $falseFound = "false"; } return $falseFound; } Now this all works fine, I just need it to check the actual nodeValue (anchor text as well) meaning check this: <a href="http://google.com">Google</a> There is a mysql table called "allowed_anchors" with 2 rows "id" and "anchor" I need it to check if the nodeValue matches 1 of the allowed_anchors from the table. If anyone knows how I can do this that would be very great i have been trying to figure it out for hours with no luck. Thanks very much for any help to come. Folks, I have a dropdown, once values are selcted, these values should be put in a URL structure so that it matches with the one MoD_rewrite rule in my .htaccess. Here is my Mod_Rewrite Rule: RewriteRule ^(.*)/([^/]*)\.html$ search.php?q=$1&sc=$2 [QSA,L] Here is my Dropdown Code: <div id="search" > <form id="searchform" method="get" action="search.php"> <label>Search By Brand/ Manufacturer: </label> <select name="q"> <option value="SelectBrand">Select Brand</option> <?php if(isset($this->search->options)): ?> <?php foreach($mfg as $lolachild): ?> <option value="<?php echo $lolachild; ?>"><?php echo ucwords($lolachild); ?></option> <?php endforeach; ?> <?php endif; ?> </select> <select name="sc"> <option value="All"><?php eprint(LangAll); ?></option> <?php if(isset($this->search->options)): ?> <?php foreach($this->search->options as $cat): ?> <option value="<?php echo $cat->value; ?>"><?php echo $cat->name; ?></option> <?php endforeach; ?> <?php endif; ?> </select> <input type="submit" value="<?php eprint(LangSearch); ?>" /> </form> </div> Problem is, upon Submit, it goes to this link structu http://mydomain.co.uk/search.php?q=fisher&sc=302 It should rather be: http://au2.co.uk/fisher/302.html What am i missing or doing wrong? Cheer Natasha I'm just attempting to learn how PHP handles things and I can't quite wrap my head around how to apply Selected to the final Option and show the Traits for the Character based on the Selected Option. I understand this might need POST, if it does, I would appreciate a bit of help on how I would set this up as POST since I didn't think a drop down required a submit button. Code: [Select] $character= array (array(Name=>"Barry","Class"=>"Fighter",Level=>1,Str=>10,Dex=>10,"Int"=>10),array(Name=>"Lindehar","Class"=>"Ranger",Level=>1,Str=>10,Dex=>10,"Int"=>10),array(Name=>"Verelden","Class"=>"Mage",Level=>1,Str=>10,Dex=>10,"Int"=>10)); print "Select a Character:<br /><select>"; foreach($character as $array_num) { foreach($array_num as $char_trait=>$trait_value) { if($char_trait==Name) { $selected_value=""; $generated_chars="<option selected=".$selected_value." value='".$char_trait."'>".$char_trait.": ".$trait_value."</option>"; print $generated_chars; if($selected_value=/".$char_trait.": Barry"/") { foreach($char_trait=="Barry") { print "<h4>".$char_trait.": ".$trait_value."</h4>"; } } } } } print "</select><p />"; mysql.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("ckeditor",$con); ?> --------------------------------------------------------- add.php <?php include("mysql.php"); if(isset($_POST["button2"])) { $sql="INSERT INTO cktext (section) VALUES ('$_POST[select2]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } ?> ----------------------------------------------------------------- home.php <form id="form1" name="form1" method="post" action="add.php"> <tr> <td>Section:</td> <td><select name="select2" id="select2"> <option selected="selected" value="MALE">Male</option> <option selected="" value="FEMAIL">FEMAIL</option> </select></td> </tr> <input type="submit" name="button2" id="button2" value="Upload" /> </form> In DATABASE :- cktext table attribute "section" is varchar type. BUT IT RETURN ME BLANK OUTPUT. Hopefully someone can help, firstly i am a newbie at php coding but keen to learn more.
Here is my problem
The database is built correctly with all the information i need, the first part is the dropdown menu which you select a car, next you choose a month and mileage - from there it shall show you the correct price for each one. There is columns for each price, mileage and months i just need to figure out how best to start this thing.
I first started by this
$query = "SELECT DISTINCT Full_Description FROM import"; Hi, I'll try and keep this brief but it really is a case of searching for needle in a haystack... I've just started working for a UK charity whose main activity is supported by a massive website. Stacks of information sheets, 3 distinct forums (each about the size of Freaks here), numerous blogs, events pages, webinars etc. etc. Essentially, it is an on-line free community that serves the needs of a very sizeable percentage of man and womankind. Like many charities it relies on gratis contributions from those with time or money to spare. I don't have either, but I do believe in what they are doing. The problem is that that the site itself has grown or rather mutated to become a huge data repository, built from a number of contributors with different skills sets and ways of doing things. At the back of it lurks a CMS which staff (a limited number) use to update site content. 95% of the site is in PHP, with a host of other ingredients thrown into the pot (Tiny-MCE, Perl, Ajax, Fancybox, html5, flash, blah and blah). The problem is in the CMS when someone tries to enter a date beyond 2014 there is no option to do so - -.i.e. that's as far as the dropdown goes. I can see the problem but can't find the offending script/files. Anywhere. Here's a snippet from the viewable source for those with keener eyesight:
<form action="index.php?content=data_universal_new&table=events" method="post" ENCTYPE="multipart/form-data" > <input type="hidden" name="change" value=""> <table summary="" border="0"> <tr> <td valign="top">Title</td> <td><input type="text" name="titlex" size="30" maxlength="256" value=""></td> </tr> <tr> <td valign="top">Microsite</td> <td> <select name="micrositex"> <option value="INF UK" > INF UK</option> <option value="MTL" > MTL</option> <option value="ACE BABES" > ACE BABES</option> </select> </td> </tr> <tr> <td valign="top">Short description</td> <td><textarea name="short_descriptionx" cols="40" rows="5" ></textarea></td> </tr> <tr> <td valign="top">Thumbnail</td> <td> <input type="file" name="graphic[thumbnailx]"> <input type="checkbox" name="deletepic[thumbnail]" value="yes"> Delete? </td> </tr> <tr> <td valign="top">Main page</td> <td> <div id="tm"><textarea id="elm1" name="main_pagex" style=" height: 400px;width:460px;" class="mceEditor"></textarea></div> <p> <script type="text/javascript"> function toggleEditor(id) { if (!tinyMCE.getInstanceById(id)) tinyMCE.execCommand('mceAddControl', false, id); else tinyMCE.execCommand('mceRemoveControl', false, id); } </script> <div><a href="javascript:toggleEditor('elm1');">[Add/Remove editor]</a></div> <a href="upload.php" title="Upload Documents" class="iframe">Upload Documents</a> <span class="tooltip" title="Click here to start the document uploader,The documents will be available to link to in the link list drop-down"> <img src="../images/help.png" border="0" width="15" height="15" alt="" align="top" > </span> </p> </td> </tr> <tr> <td valign="top">Date</td> <td> <select name="date[4]"> <option >1</option> <option >2</option> <option >3</option> <option >4</option> <option >5</option> <option >6</option> <option >7</option> <option >8</option> <option >9</option> <option >10</option> <option >11</option> <option >12</option> <option >13</option> <option >14</option> <option >15</option> <option >16</option> <option >17</option> <option >18</option> <option >19</option> <option >20</option> <option >21</option> <option >22</option> <option >23</option> <option >24</option> <option selected>25</option> <option >26</option> <option >27</option> <option >28</option> <option >29</option> <option >30</option> <option >31</option> </select> <select name="date[3]"> <option value="1" >Jan</option> <option value="2" >Feb</option> <option value="3" >Mar</option> <option value="4" >Apr</option> <option value="5" >May</option> <option value="6" >Jun</option> <option value="7" >Jul</option> <option value="8" >Aug</option> <option value="9" >Sep</option> <option value="10" >Oct</option> <option value="11" selected>Nov</option> <option value="12" >Dec</option> </select> <select name="date[5]"> <option value="2002" >2002</option> <option value="2003" >2003</option> <option value="2004" >2004</option> <option value="2005" >2005</option> <option value="2006" >2006</option> <option value="2007" >2007</option> <option value="2008" >2008</option> <option value="2009" >2009</option> <option value="2010" >2010</option> <option value="2011" >2011</option> <option value="2012" >2012</option> <option value="2013" >2013</option> <option value="2014" selected >2014</option> </select> </td></tr> <tr> <td> </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> </div> <div id="man_div"> <p><a href="index.php?content=data_universal_new&add=yes&table=events">Add event</a></p>Hmm. Any thoughts would be greatly appreciated. Edited by Ch0cu3r, 25 November 2014 - 07:15 AM. 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 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 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'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 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? 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)); ?> What I'm wanting to do is pass the $propertyid = "1"; threw my select value as you can see. so it passes variable so to speak.' Code: [Select] print "<td>Control:<form action=\"dashboard.php\" method=\"GET\" target=\"_self\"> <select name=\"control\" onChange=\"this.form.submit()\"> <option selected></option> <option>Take a Payment</option> <option>Print Ledger </option> <option>-----------------</option> <option value=\"comadd?propid=$propertyid\">Add Communication</option> <option>----------------</option> <option>Modify Property</option> <option>Remote Property</option> </select></td>"; Hi.. I got problem in logic on my problem in select option. Here is my scenario. I have select option which has a compound list: example: P28 P30 P32 P33 P35 and I have tables which has a total count of compound that was already transact. for example I already transact 10 P28 compound. it will save in kanban_checker table field Total. and I have parameter_settings table which has the maximum and minimum per compound: fields----------data P28------------P28 P28_max-----10 P28_min------6 P30------------P28 P30_max-----10 P30_min------6 P32------------P28 P32_max-----10 P32_min------6 P33------------P28 P33_max-----10 P33_min------6 now the logic is: if P28 total = P28_max then notify that he already reach the maximum..it will not produce P28 because he already reach the maximum. if P28 total = P28_min then produce P28. same with other compound. Now, I got a problem in coding and logic, because in the select option I'm not the one who code it.. I just one who need to add the additional function.. here is the code for select option and the function that was created by other, Code: [Select] $smarty->assign('text_name1','Compound Code'); $smarty->assign('compoundIndexValue', array('0', 'P28', 'P30', 'P32', 'P33', 'P35', 'P35M', 'P38', 'P40', 'P41', 'P42', 'P43', 'P46', 'P47', 'PXX', 'P35W')); <tr> <td class="tdMainText">{$text_name1}</td> <td> <select class="tdMainElement" id="selCompound" onchange="isSelected('selCompound','txtLotCode')" onclick="clearNotify()" onblur="this.focus();" onkeypress="return false">{html_options values=$compoundIndexValue output=$names selected="0"} </select> </td> </tr> <script type="text/javascript"> function isSelected(obj1, obj2) { if (!document.getElementById(obj1).disabled) { document.getElementById(obj1).disabled = true; } if (document.getElementById('clear').disabled) { document.getElementById('clear').disabled = false; //enable it } if ((document.getElementById('chkDownGrade') != null)) { if (!document.getElementById('chkDownGrade').disabled) { document.getElementById('chkDownGrade').disabled = true; } } if (document.getElementById(obj2).disabled) { document.getElementById(obj2).disabled = false; } document.getElementById(obj2).focus(); document.getElementById(obj2).focus(); //notify("Gain Maximum Total"); } function disable() { if (!document.getElementById('clear').disabled) { document.getElementById('clear').disabled = true; } else { document.getElementById('clear').disabled = false; } } function clearNotify() { if (document.getElementById('notice') != null) { document.getElementsByTagName('body')[0].removeChild(document.getElementById('notice')) //>> clear the box } } </script> and here is the code that I tried to add: Code: [Select] $compound = mysql_real_escape_string($_POST['compound']); $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 FROM parameter_settings"; $res_pcode = mysql_query($sql, $con); while($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']; } // $sub_lotcode = substr($lotCode, 9, 4); $sql = "SELECT PCODE, total FROM kanba_checker WHERE PCODE = '$sub_lotcode' 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'>alert(P28 gain total maximum)</script>"; } else{ } but I don't know if my code and my logic is correct. I think I did to add function. But I don't know how.. I hope someone can help me or guide me to solve my problem. Thank you so much.. If I have a variable and a hard coded select dropdown, what is the easiest way to compare the variable with the value and set that particular option's selected attributed to selected? |