Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Autocomplete Input Box
    primarykey
    data
    text
    <p>So I created an auto complete box using jQuery and PHP to pull the content from the database, and it's working fine, except when I go to type in the input box it pulls back all the results, instead of the results similar to what I'm typing. </p> <p>So if you type <strong>Test</strong> it pulls back:</p> <pre><code>This is a Test </code></pre> <p>Instead of displaying</p> <pre><code>Test </code></pre> <p><strong>Here is my HTML</strong></p> <pre><code>&lt;input type="text" id="group_name" name="group_name"&gt; </code></pre> <p><strong>Here is the jQuery I'm using</strong></p> <pre><code>&lt;script&gt; $(document).ready(function() { $( "#group_name" ).autocomplete({ source: "/wuzhapnn/php/data_stream/group_names", select: function(event, ui) { $("#f").submit(); } }); }); &lt;/script&gt; </code></pre> <p><strong>Here is my php page</strong></p> <pre><code>if ($_GET['run'] == 'group_names') { // pulls live data from database $db = db_open(); $query = "SELECT group_name FROM groups"; $result = db_query($db, $query); if (db_num_rows($result) &gt; 1) { $result = db_fetch_all($result); foreach ($result as $key=&gt;$value) { $group_names_array[] .= $value['group_name']; } } else { } echo json_encode(array_values(array_unique($group_names_array))); } </code></pre> <ul> <li><strong>Recent Updates</strong></li> </ul> <p><strong>New jQuery</strong></p> <pre><code>&lt;script&gt; var availableName; $.getJson('/wuzhapnn/php/data_stream',function(response){ availableName = response; }); $(document).ready(function() { $( "#group_name" ).autocomplete({ source: availableName, select: function(event, ui) { $("#f").submit(); } }); }); &lt;/script&gt; </code></pre> <p><strong>New PHP Page</strong></p> <pre><code>if ($_GET['run'] == 'group_names') { // pulls live data from database $db = db_open(); $query = "SELECT group_name FROM groups WHERE group_name LIKE '%".$_GET['term']."%'"; $result = db_query($db, $query); if (db_num_rows($result) &gt; 1) { $result = db_fetch_all($result); foreach ($result as $key=&gt;$value) { $group_names_array[] .= $value['group_name']; } } else { } echo json_encode(array_values(array_unique($group_names_array))); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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