Things you'll need:
1. Client side code - i.e. JavaScript
2. PHP + JSON PHP library (I can provide)
3. AJAX
Here is what needs to be done:
Server side
1. Create a PHP script on the server - we'll call it
HttpAutoSuggest.php
2. The script will take a parameter via the URL called "search" - this is accessible via
$_GET in the PHP script. This will be the search term we use to fetch a list of user names.
3. Query the MySQL database using a
WHERE user_name LIKE query.
4. Use
mysql_fetch_assoc to fetch all the results into an array.
5. Convert this array into an JSON (JavaScript Object Notation) string.
6. Output the JSON string.
Client side
1. Each time the user releases a key (see:
onkeyup) in the text box - send an XMLHttpRequest to your
HttpAutoSuggest.php script.
2. You can get the current typed text by using the
value property of the text box.
3. the request URL should look like this:
http://path/to/script/HttpAutoSuggest.php?search={SEARCH_HERE}
4. Replace
{SEARCH_HERE} with the current value of the text box.
5. After receiving the response back from the server (a JSON string), call
eval on the JSON string.
6. Parse the converted object from
eval and display a dropdown box with the results.
Give me a few minutes to cook up a quick framework/code sample for you
