jquery ui autocomplete with database

后端 未结 7 2111
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 08:41

I fairly new to JQuery and perhaps trying to achieve something that might be abit harder for a beginner. However I am trying to create an autocomplete that sends the curren

7条回答
  •  天涯浪人
    2020-12-08 09:07

    Simple Jquery ui autocomplete, for those who might need it.

    //select data from the table
    $search = $db->query('SELECT Title from torrents');
    
    //then echo script tags and variables with php
    
     $(function() {
      var availableTags = [';
     foreach ($search as $k) {
      echo '"'.$k['Title'].'",';
    }
      echo '];
    $( "#tags" ).autocomplete({
      minLength:2, //fires after typing two characters
      source: availableTags
    });
    });
    ';
    
     ?>
    

    your html form

    
    

提交回复
热议问题