title: PHP Use select value to search and display result to textbox
body: <p>My Selectbox Items from aircraft table </p>
  
  <pre><code>&lt;select name="selectaircraft"&gt;
  &lt;option id="0"&gt;-- Select Aircraft -- &lt;/option&gt;
  &lt;?php
  require("dbc.php");
  $getallaircraft = mysql_query("SELECT * FROM aircrafttable");
  while($viewallaircraft = mysql_fetch_array($getallaircraft)){
  ?&gt;
  &lt;option id="&lt;?php echo $viewallaircraft['ID']; ?&gt;"&gt;
  &lt;?php echo $viewallaircraft['aircraft'] ?&gt; &lt;/option&gt;
  &lt;?php } ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>hi guys im trying to use the the value of selectaircraft to search and display the result to textbox.. here is my code so far</p>
  
  <pre><code>&lt;?php
     require("dbc.php");
         $getallconfig = mysql_query("SELECT * FROM aircrafttable WHERE aircraft LIKE 'PR200'");  
     while($viewallconfig= mysql_fetch_array($getallconfig)){
  
  ?&gt;
     &lt;input type="text" name="aconfig "value="&lt;?php echo $viewallconfig['config'];      ?&gt;" /&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>As you can see, I only put PR200 to search, my question is how can i use the select value instead? I also want the search query to happen everytime i click the select box.</p>
  
  <p>guys can some1 help me? i know how to code this in VB6 it will be like this</p>
  
  <p>assume : select name or in VB6 combobox = selectbox</p>
  
  <pre><code>Private Sub Combo3_Click()
  adodc1.recorsource ="Select * from aircrafttable where aircraft = " &amp; selectbox &amp; "'"
  adodc1.refresh
  
  
  Text1.Text = Adodc1.Recordset("aircraft")
  </code></pre>
  
  <p>everytime i click combo/selectbox the query will perform and give different answer to textbox.
  i dont know how to do this in PHP pls help!</p>
  
  <p>Edited Added all codes</p>
  
  <pre><code>    &lt;form action="addrecord.php" method="post" &gt;
  
  
      &lt;table border=1&gt;
      &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
      &lt;strong&gt;Area:&lt;/strong&gt; &lt;/td&gt;
      &lt;td&gt;
  
   &lt;input type="text" required="required" name="aarea" size=10 /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
      &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
      &lt;strong&gt;Aircraft:&lt;/strong&gt;&lt;/td&gt;
  
  
  
  
  
  &lt;td&gt;
  
  &lt;form method="post" action="aircraft.php"&gt;
   &lt;select name="selectaircraft" onchange="this.form.submit();"&gt;
       &lt;option id="0"&gt;Aircraft&lt;/option&gt;
  &lt;?php
        require("dbc.php");
        $getallaircraft = mysql_query("SELECT * FROM aircrafttable");
        while($viewallaircraft = mysql_fetch_array($getallaircraft)){
  ?&gt;
        &lt;option id="&lt;?php echo $viewallaircraft['ID']; ?&gt;"&gt;
  &lt;?php 
        echo $viewallaircraft['aircraft'] ?&gt; &lt;/option&gt;
  &lt;?php } ?&gt;
      &lt;/select&gt;
  
  
  
  &lt;?php
          require("dbc.php");
          if(isset($_POST)){
          $takeaircraft = mysql_real_escape_string($_POST['selectaircraft']);     
  
  {
  
  ?&gt;
     &lt;input type="text" name="aaircraft" size=3 value="&lt;?php echo $takeaircraft;  ?&gt;" /&gt;
  &lt;?php } 
  }?&gt;
  
  
  &lt;/form&gt;
  
  
  &lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Flight:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;&lt;input type="text"  name="aflight" size=10  /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
   &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Configuration:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;
  
  
  
   &lt;?php
          require("dbc.php");
          if(isset($_POST)){
          $selectaircraft = mysql_real_escape_string($_POST['selectaircraft']);     
           $getallconfig = mysql_query("SELECT * FROM aircrafttable WHERE aircraft LIKE '".$selectaircraft."'"); 
   while($viewallconfig= mysql_fetch_array($getallconfig)){
  
  ?&gt;
     &lt;input type="text" name="aconfig" value="&lt;?php echo $viewallconfig['config'];      ?&gt;" /&gt;
  &lt;?php } 
  }?&gt;
  
   &lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Month:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;
   &lt;select name="amonth"&gt;
          &lt;option value="na"&gt;Month&lt;/option&gt;
          &lt;option value="January"&gt;January&lt;/option&gt;
     &lt;/select&gt;
   &lt;/td&gt;&lt;/tr&gt;
  
   &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Frequency:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;&lt;span style="font-size:11px; font-weight:bolder" &gt;
  
      Mon&lt;input type="checkbox" id='check1' onClick='checkmon()'&gt;
  &lt;input type="hidden"  id="txt1" name="hiddenmon" value="n/a"&gt;
  
  
     Tue&lt;input type="checkbox" id='check2' onClick='checktue()'&gt;
  &lt;input type="hidden"  id="txt2" name="hiddentue" value="n/a"&gt;
  
     Wed&lt;input type="checkbox" id='check3' onClick='checkwed()'&gt;
  &lt;input type="hidden"  id="txt3" name="hiddenwed"  value="n/a"&gt;
  
  
     Thu&lt;input type="checkbox" id='check4' onClick='checkthu()'&gt;
  &lt;input type="hidden"  id="txt4" name="hiddenthu" value="n/a"&gt;
  
    Fri&lt;input type="checkbox" id='check5' onClick='checkfri()'&gt;
  &lt;input type="hidden"  id="txt5" name="hiddenfri"  value="n/a"&gt;
  
    Sat&lt;input type="checkbox" id='check6' onClick='checksat()'&gt;
  &lt;input type="hidden"  id="txt6" name="hiddensat"  value="n/a"&gt;
  
    Sun&lt;input type="checkbox" id='check7' onClick='checksun()'&gt;
  &lt;input type="hidden"  id="txt7" name="hiddensun" value="n/a"&gt;
  
  
   &lt;/span&gt;
   &lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Menu:&lt;/strong&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="amenu" size=10 /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Cycle:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;
   &lt;select name="acycle"&gt;
          &lt;option value="na"&gt;Cycle&lt;/option&gt;
          &lt;option value="Cycle 1"&gt;Cycle 1&lt;/option&gt;
  
          &lt;/select&gt;
  
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Items:&lt;/strong&gt; &lt;/td&gt;
   &lt;td&gt;
   &lt;select name="aitem"&gt;
          &lt;option value="na"&gt;Items&lt;/option&gt;
  
                  &lt;/select&gt;
  
  
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;STD Time:&lt;/strong&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="astdtime" size=5 /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  &lt;tr&gt;&lt;td bgcolor="#999999"&gt;
  &lt;strong&gt;Quantity:&lt;/strong&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="aqty" size=5 /&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;td colspan="2" align="right" bgcolor="#999999"&gt;
  &lt;input type='submit' name="add" value="Add Records" /&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
   &lt;/table&gt;
  
  
  
      &lt;/form&gt;
  </code></pre>