How instead of ActionScript, AppleScript, etc., insert data from mysqli this

$result = mysqli_query($db, "SELECT * FROM users"); $myrow = mysqli_fetch_array($result); $myrow['login'];//вот это должно вывести 

that's the jQuery code itself

  $( function() { var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $( "#tags" ).autocomplete({ source: availableTags }); } ); 
 <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> </head> <body> <div class="ui-widget"> <label for="tags">Tags: </label> <input id="tags"> </div> </body> </html> 

  • What does the data format look like that returns a query to mysqli ? - Vyacheslav Danshin
  • @VyacheslavDanshin Excuse me? Can I have something clearer - BedOmar
  • @VyacheslavDanshin returns text if I understand correctly - BedOmar
  • Apparently you are running the code on the server side, which receives data from the database, and you want to push this data on the front of the "ui-widget", I understand correctly? then for this you need to make a request to the server and process a response from it, and as long as I do not understand in what format the server will return the data to you, I can’t write you the client code for binding this data to the widget. - Vyacheslav Danshin
  • @VyacheslavDanshin so what do you write that would help you? - BedOmar

2 answers 2

Straight into the forehead and shove if the variable is available for the file where JS:

 $( function() { var availableTags = <?php $myrow['login'] ?> } 

you may have to cycle through if it is a php-array:

 $( function() { var availableTags = <?php foreach ($myrow['login'] as $login) { echo $login.','; } ?>; }; 

    click execute and try to enter something in Latin, options of google repositories will be offered

     $( function() { var availableTags = []; $.get( "http://api.github.com/users/google/repos", function( data ) { data.forEach(function(item) { availableTags.push(item.name); }) }); $( "#tags" ).autocomplete({ source: availableTags }); }); 
     <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> </head> <body> <div class="ui-widget"> <label for="tags">Tags: </label> <input id="tags"> </div> </body> </html> 

    jQuery.get () documentation

    • and how to add data to a file with tags - BedOmar
    • @BedOmar which file is tagged ??? You asked how you insert the data into the widget, I answered your question. Apply it to your situation, I explained that you need to make a request to the server that will respond with the data you need, but you persistently refuse to provide the response format of your server and I gave you an example of how to implement it on the front without this data. Or do you want me to write the server part for you? - Vyacheslav Danshin
    • if you can write something to the server and write) - BedOmar