Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Autocomplete to Populate a Form how to connect to mysql
    primarykey
    data
    text
    <p>jQuery Autocomplete to Populate a Form how to connect to mysql</p> <p>this code is showing array results and i want to connect mysql database how can i connect to mysql please help me to fix this issue</p> <p>autocomplete.htm</p> <pre><code>&lt;link rel="stylesheet" href="http://static.jquery.com/ui/css/base2.css" type="text/css" media="all" /&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ var ac_config = { source: "/ajax/demo_cities.php", select: function(event, ui){ $("#city").val(ui.item.city); $("#state").val(ui.item.state); $("#zip").val(ui.item.zip); }, minLength:1 }; $("#city").autocomplete(ac_config); }); &lt;/script&gt; &lt;form action="#" method="post"&gt; &lt;p&gt;&lt;label for="city"&gt;City&lt;/label&gt;&lt;br /&gt; &lt;input type="text" name="city" id="city" value="" /&gt;&lt;/p&gt; &lt;p&gt;&lt;label for="state"&gt;State&lt;/label&gt;&lt;br /&gt; &lt;input type="text" name="state" id="state" value="" /&gt;&lt;/p&gt; &lt;p&gt;&lt;label for="zip"&gt;Zip&lt;/label&gt;&lt;br /&gt; &lt;input type="text" name="zip" id="zip" value="" /&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>demo_cities.php</p> <pre><code>&lt;?php // Data could be pulled from a DB or other source $cities = array( array('city'=&gt;'New York', state=&gt;'NY', zip=&gt;'10001'), array('city'=&gt;'Los Angeles', state=&gt;'CA', zip=&gt;'90001'), array('city'=&gt;'Chicago', state=&gt;'IL', zip=&gt;'60601'), array('city'=&gt;'Houston', state=&gt;'TX', zip=&gt;'77001'), array('city'=&gt;'Phoenix', state=&gt;'AZ', zip=&gt;'85001'), array('city'=&gt;'Philadelphia', state=&gt;'PA', zip=&gt;'19019'), array('city'=&gt;'San Antonio', state=&gt;'TX', zip=&gt;'78201'), array('city'=&gt;'Dallas', state=&gt;'TX', zip=&gt;'75201'), array('city'=&gt;'San Diego', state=&gt;'CA', zip=&gt;'92101'), array('city'=&gt;'San Jose', state=&gt;'CA', zip=&gt;'95101'), array('city'=&gt;'Detroit', state=&gt;'MI', zip=&gt;'48201'), array('city'=&gt;'San Francisco', state=&gt;'CA', zip=&gt;'94101'), array('city'=&gt;'Jacksonville', state=&gt;'FL', zip=&gt;'32099'), array('city'=&gt;'Indianapolis', state=&gt;'IN', zip=&gt;'46201'), array('city'=&gt;'Austin', state=&gt;'TX', zip=&gt;'73301'), array('city'=&gt;'Columbus', state=&gt;'OH', zip=&gt;'43085'), array('city'=&gt;'Fort Worth', state=&gt;'TX', zip=&gt;'76101'), array('city'=&gt;'Charlotte', state=&gt;'NC', zip=&gt;'28201'), array('city'=&gt;'Memphis', state=&gt;'TN', zip=&gt;'37501'), array('city'=&gt;'Baltimore', state=&gt;'MD', zip=&gt;'21201'), ); // Cleaning up the term $term = trim(strip_tags($_GET['term'])); // Rudimentary search $matches = array(); foreach($cities as $city){ if(stripos($city['city'], $term) !== false){ // Add the necessary "value" and "label" fields and append to result set $city['value'] = $city['city']; $city['label'] = "{$city['city']}, {$city['state']} {$city['zip']}"; $matches[] = $city; } } // Truncate, encode and return the results $matches = array_slice($matches, 0, 5); print json_encode($matches); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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