title: auto generate text box with database values when drop down list selected
body: <p>I have two interdependent drop drown, 2nd drop down value populates when 1st drop down value selected, When i select 2nd drop down it has to populate text boxes with the values stored in database. </p>
  
  <p>My drop down list is working but i am not getting how to populate text boxes when 2nd drop down selected. </p>
  
  <p>Here is my code</p>
  
  <p>jquery</p>
  
  <pre><code>&lt;script&gt;
  
      function showItems(sel) {
          var cat_id = sel.options[sel.selectedIndex].value;  
          $("#output1").html( "" );
  
          if (cat_id.length &gt; 0 ) {
  
           $.ajax({
                  type: "POST",
                  url: "fetch_items.php",
                  data: "cat_id="+cat_id,
                  cache: false,
                  beforeSend: function () {
                      $('#output1').html('&lt;img src="loader.gif" alt="" width="24" height="24"&gt;');
                  },
                  success: function(html) {    
                      $("#output1").html( html );
                  }
              });
          }
      }
      &lt;/script&gt;
  </code></pre>
  
  <p>Form(dropdown)</p>
  
  <pre><code>&lt;div class="formSep"&gt;
  
  &lt;?php
  $sql2 = "SELECT * FROM item_category";
  $query2 = mysql_query($sql2);
  ?&gt;
  
  &lt;select name="category" onChange="showItems(this);"&gt;
    &lt;option value=""&gt;Item Category&lt;/option&gt;
  &lt;?php while ($rs2 = mysql_fetch_array($query2)) { ?&gt;
    &lt;option value="&lt;?php echo $rs2["item_id"]; ?&gt;"&gt;&lt;?php echo $rs2["name"]?&gt;&lt;/option&gt;
  &lt;?php } ?&gt;
  &lt;/select&gt;
  
  
  
  
   &lt;div id="output1"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>fetch_items.php</p>
  
  <pre><code>&lt;?php
  
  error_reporting(0);
  include("../connect.php");
  include("../admin_auth.php"); 
  
  $cat_id = ($_REQUEST["cat_id"] &lt;&gt; "") ? trim( addslashes($_REQUEST["cat_id"])) : "";
  if ($cat_id &lt;&gt; "" ) { 
  $sql = "SELECT * FROM items where category=".$cat_id."";
  $count = mysql_num_rows( mysql_query($sql) );
  if ($count &gt; 0 ) {
  $query = mysql_query($sql);
  ?&gt;
  
  &lt;select name="items"&gt;
      &lt;option value=""&gt;Items&lt;/option&gt;
      &lt;?php while ($rs = mysql_fetch_array($query)) { ?&gt;
      &lt;option value="&lt;?php echo $rs["name"]; ?&gt;"&gt;&lt;?php echo $rs["name"]; ?&gt;&lt;/option&gt;
      &lt;?php } ?&gt;
  &lt;/select&gt;
  
  &lt;?php 
      }
  }
  ?&gt;
  </code></pre>
  
  <p>in textboxes i should get values from items table, for that query </p>
  
  <pre><code>$m1 = "select * from order_line_items where order_id=".$order_id."";
                     $result = mysqli-&gt;query($m1);
  
                     $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
  </code></pre>
  
  <p>Please suggest me how to generate text boxes.</p>