title: Autocomplete all the fields of a form by selecting only the id - PHP Mysql
body: <p>I briefly explain my goal, I have created for my client two different areas an area to select advertising facilities and an area where he registers his customers, now I would like to create the order area, where it will go inside to record in a single step form associating the values ​​of the advertising system field with those of a customer thus creating = association between a product and its customer.</p>
  
  <p>I was seeing and I found many tutorials on how to create a form that can be autocompiled with a curtain but all the examples that I found auto fill only a part of the form.
  How can I for example by selecting the id of a product that all the information of the latter are automatically autocompiled.</p>
  
  <p>for example I have 6 fields
  id</p>
  
  <p>length</p>
  
  <p>height</p>
  
  <p>longitude</p>
  
  <p>latitude</p>
  
  <p>guy</p>
  
  <p>by selecting only the id, the other 5 will be self-compiled directly</p>
  
  <p>I'm trying with the selection of the fields generated by the database with the autocompilation but my visualization comes out completely unpacked I would like to have the user write in the form field and pull out a curtain</p>
  
  <p>I put the code</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  $connection = new mysqli('localhost', 'root', 'root', 'ca2solution');
  
  $query_string = "SELECT name FROM country WHERE name LIKE '%$q%'";
  
  $query = mysqli_query($connection, $query_string);
  
  ?&gt;
  
  &lt;form role="form" action="" method="post"&gt;
      &lt;div class="row setup-content-2" id="step-1"&gt;
          &lt;div class="col-md-12"&gt;
              &lt;h3 class="font-weight-bold pl-0 my-4"&gt;&lt;strong&gt;Tipo di Impianto&lt;/strong&gt;&lt;/h3&gt;
              &lt;div id="searchBox" class="form-group md-form"&gt;
  
  &lt;?php
  
  while($row = mysqli_fetch_assoc($query)){ ?&gt;
  
                  &lt;label for="yourEmail-2" data-error="wrong" data-success="right"&gt;Email&lt;/label&gt;
                  &lt;input id="searchBox" type="text" value="&lt;?php echo $row['name'] ;?&gt;" required="required" class="form-control validate"&gt;
                  &lt;div id="response"&gt;&lt;/div&gt;
  
  &lt;?php } ?&gt;
  
  
  
  
              &lt;/div&gt;
              &lt;button class="btn btn-mdb-color btn-rounded nextBtn-2 float-right" type="button"&gt;Next&lt;/button&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/form&gt;
  
  
          &lt;script type="text/javascript"&gt;
              $(document).ready(function () {
                  $("#searchBox").keyup(function () {
                      var query = $("#searchBox").val();
  
                      if (query.length &gt; 0) {
                          $.ajax(
                              {
                                  url: 'testtre.php',
                                  method: 'POST',
                                  data: {
                                      search: 1,
                                      q: query
                                  },
                                  success: function (data) {
                                      $("#response").html(data);
                                  },
                                  dataType: 'text'
                              }
                          );
                      }
                  });
  
                  $(document).on('click', 'li', function () {
                      var country = $(this).text();
                      $("#searchBox").val(country);
                      $("#response").html("");
                  });
              });
          &lt;/script&gt;
  </code></pre>
  
  <p>image<a href="https://i.stack.imgur.com/kNnHB.png" rel="nofollow noreferrer">enter image description here</a></p>