title: Return User's id from mysql table with autocomplete
body: <p>Simply I want to handle <code>id</code> column's value seperately to use it in a hidden field for mySQL. But when I fetch n<code>ame,surname,id</code> they are appearing in search text field also <code>id</code> value appearing. <em>I only want to use id in hidden field's value area.</em> And only Name, Surname must appear in text field. How can I set id's value to hidden field instantly?</p>
  
  <p><img src="https://i.stack.imgur.com/bpon6.jpg" alt="enter image description here"></p>
  
  <p><strong>autocomplete.php</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php 
  include 'config/db.connect.php';
  $return_arr = array();
  
  
  if (isset($_GET['term'])){
  try {
  
      $stmt = $db-&gt;prepare('SELECT id,user_username,name,surname FROM user WHERE name LIKE :receiver or surname LIKE :receiver or user_username LIKE :receiver');
      $stmt-&gt;execute(array('receiver' =&gt; '%'.$_GET['term'].'%'));
  
      while($row = $stmt-&gt;fetch()) {
           $return_arr['name'] = $row['name'];
           $return_arr['surname']= $row['surname'];
           $return_arr['id']= $row['id'];
      }
  
  } catch(PDOException $e) {
      echo 'ERROR: ' . $e-&gt;getMessage();
  }
  echo json_encode($return_arr);
  
   }
  
  ?&gt;
  </code></pre>
  
  <p><strong>script in my form's page</strong>
  </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function() {
  
  //autocomplete
  $("#receiver").autocomplete({
      source: "autocomplete.php",
      minLength: 1,
  
      select: function(event, ui) { 
      $("#receiver_id").val(ui.item.value); 
  }
  
  });             
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>FORM</strong>
  </p>
  
  <pre><code>&lt;form action="action_send_message.php" method="POST"  &gt;
       &lt;label for="receiver"&gt;Receiver&lt;/label&gt;
       &lt;input type="text" name="receiver" id="receiver" placeholder="Receiver" class="span12" /&gt;
       &lt;input type="hidden" name="receiver_id" id="receiver_id" value=""/&gt;
       &lt;textarea id="messagebody" name="message_body" class="wysihtml5 span12" rows="5" placeholder="Mesajınızı Yazın"&gt;&lt;/textarea&gt;
       &lt;button type="submit" class="btn btn-large color-10"&gt;Gönder&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>