Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Save Multiple Values in jQuery Autocomplete to MySQLi DB?
    text
    copied!<p>I'm just learning about the jQuery AutoComplete Widget. The values pop up with a comma nicely. So, the visual display to the user is great.</p> <p>My issue is how do I save the multiple values to a MySQLi database?</p> <p>Here is the code:</p> <pre><code> &lt;script&gt; $(function() { var availableskills = [ "ActionScript", "AppleScript", .......... more languages "XML" ]; function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } $( "#skills" ) // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB &amp;&amp; $( this ).data( "autocomplete" ).menu.active ) { event.preventDefault(); } }) .autocomplete({ minLength: 0, // could have source as a "url" source: function( request, response ) { // delegate back to autocomplete, but extract the last term response( $.ui.autocomplete.filter( availableskills, extractLast( request.term ) ) ); }, focus: function() { // prevent value inserted on focus return false; }, select: function( event, ui ) { var terms = split( this.value ); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the comma-and-space at the end terms.push( "" ); this.value = terms.join( ", " ); return false; } }); }); &lt;/script&gt; </code></pre> <p>Now, here's my input id for letting the user select the skills:</p> <pre><code> &lt;div class="ui-widget"&gt; &lt;!--&lt;label for="skills"&gt;Tag programming languages: &lt;/label&gt;--&gt; &lt;input type="text" id="skills" size="50" /&gt; &lt;/div&gt; </code></pre> <p></p> <p>Not sure on how to save the skills the user selects into a database. I can save data to a MySQLi db with ease; the issue is how can I take say three skills and save them into three different rows in a table in a database.</p> <p>Any help, very much appreciated.</p> <p>Ken</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload