title: Autopopulate an input field from database
body: <p>I am trying to auto-populate an input field with contents from the database, I have successfully fetched the data from the database but am confused to how to populate the input fields dynamically, in that when a user visits the page the input field is added, they find the input field already filled, but they can edit.
  Below is the code am using to fetch the data from the database:</p>
  
  <pre><code>function fetch_user_data() {  
  global $wpdb;
  $user_ID= get_current_user_id();   
  $result = $wpdb-&gt;get_results ( "SELECT * FROM mydbtable WHERE user_id =  $user_ID "); 
  foreach ( $result as $print ) {
   $data= $print-&gt;address;
  echo json_encode($data);
  }
  }
  </code></pre>
  
  <p>The html input field looks like this:</p>
  
  <pre><code>&lt;input field_type="text" name="myinputdield" id="myinputdield" value="" type="text" class="myinputdield"&gt;
  </code></pre>
  
  <p>How can I have the <code>$data</code> value auto-populated to the input field? I will appreciate any guide.</p>