Advertisement
Eather

Autocomplete error

May 4th, 2012
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. //Script::
  2.  
  3. <script>
  4. $(function() {
  5. $( "#tags" ).autocomplete({
  6. source: "pAjax/search.php",
  7. minLength: 1,
  8. select: function( event, ui ) {
  9. log( ui.item ?
  10. "Selected: " + ui.item.value + " aka " + ui.item.id :
  11. "Nothing selected, input was " + this.value );
  12. }
  13. });
  14. });
  15.  
  16. </script>
  17. //
  18.  
  19. //Search.php
  20. $term = trim(strip_tags($_GET['term']));
  21.  
  22. $result= $crud->dkQuery("SELECT username, first_name, last_name  FROM tbl_user WHERE username LIKE '%{$term}%' limit 10");
  23.  
  24.  $row_set = array(); //u have to define the row_set array
  25.  while ($row = mysql_fetch_array($result))
  26.  {
  27.      $row_set[]=htmlentities(stripslashes($row['first_name'])).' '.htmlentities(stripslashes($row['last_name']));  
  28.  }
  29.  
  30.  echo json_encode($row_set);
  31.  
  32.  
  33. //But, ami kivabe aita akta valuer under a dekhabo? ami down arrow click korleo select korbe value, jemon tumi korecila... Code er kothay vul bujtecina... amar outpur dekhay but select korle value dekhay na input a....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement