title: How to pass value from other table in form modal bootstrap
body: <p>I created a modal form to update the record with storage field that has an option and have to be taken from another table but if storage data already exist in the database then show existing data.
  I did this code but it cannot show existing data.
  If I change the code for "storage" to : ABC then it can show existing data in database.</p>
  
  <pre><code>&lt;?php
  // to connect database
  include '../connection/connect.php';
  $query_storage = mysqli_query ($connect, "SELECT * from storage ORDER BY 
  storages ASC");
  ?&gt;
  
  //code for modal bootstrap
  &lt;div id="add_data_Modal" class="modal fade"&gt;  
  &lt;div class="modal-dialog"&gt;  
  &lt;div class="modal-content"&gt;  
  &lt;div class="modal-header"&gt;  
  &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;  
                   &lt;h4 class="modal-title"&gt;Reagent Detail Information&lt;/h4&gt;  
  &lt;/div&gt;  
  &lt;div class="modal-body"&gt;  
  &lt;form method="post" id="insert_form"&gt;  
  &lt;label&gt;Storage&lt;/label&gt;  
  &lt;select class="form-control" name = "storage" id="storage" required &gt;
  &lt;?php while($row = mysqli_fetch_assoc($query_storage)){?&gt;
  &lt;option value="&lt;?php echo $row['id_storage']; ?&gt;"&gt;
  &lt;?php echo $row['storages']; ?&gt;&lt;/option&gt;";
  &lt;?php }
  ?&gt;
  &lt;/select&gt;
  &lt;br /&gt;  
  &lt;label&gt;Min Stock&lt;/label&gt;  
  &lt;input type="text" name="min_stock" id="min_stock" class="form-control" /&gt;
  &lt;br /&gt;  
  
  &lt;input type="hidden" name="reagent_id" id="reagent_id" /&gt;  
  &lt;input type="submit" name="insert" id="insert" value="Insert" class="btn btn-success" /&gt;  
  &lt;/form&gt;  
  &lt;/div&gt;  
  &lt;div class="modal-footer"&gt;  
  &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;  
  &lt;/div&gt;  
  &lt;/div&gt;  
  &lt;/div&gt;  
  &lt;/div&gt;  
  &lt;script&gt;  
  $(document).ready(function(){  
  $('#add').click(function(){  
         $('#insert').val("Insert");  
         $('#insert_form')[0].reset();  
  
    });  
  $(document).on('click', '.edit_data', function(){  
         var reagent_id = $(this).attr("id");  
         $.ajax({  
              url:"php/reagent_master/fetch.php",  
              method:"POST",  
              data:{reagent_id:reagent_id},  
              dataType:"json",  
              success:function(data){  
                   $('#storage').val(data.storages);
                   $('#min_stock').val(data.min_stock); 
                   $('#max_stock').val(data.max_stock); 
                   $('#reagent_id').val(data.id_reagent_master);  
                   $('#insert').val("Update");  
                   $('#add_data_Modal').modal('show');  
              }  
         });  
   });
  </code></pre>