You can use AJAX to accomplish this. You can write a small PHP script that makes a simple call to your database based on the characters currently entered into the search box, and then use AJAX to call it to populate your search box. I'm not going to write the entire thing out for you, because that's not what the site's for but you can start here. There's also a lot of tutorials online for stuff like this.
AJAX:
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Your browser does not support AJAX, please upgrade.");
}
}
//Create XMLHTTPRequest Object
var searchEntry = getXmlHttpRequestObject();
//Send AJAX request, do something when it sends a response
function searchSuggest() {
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
var str = document.getElementById('insertsearchboxidhere').value;
searchEntry.open("GET", 'yourphpscript.php?search=' + str, true);
searchEntry.onreadystatechange = doSearchStuff();
searchEntry.send(null);
}
}
//Function that does the work with the response
function doSearchStuff() {
if (searchReq.readyState == 4) {
var str = searchEntry.responseText;
//Set innerHTML of your stuff to str, whatever else you want
}
}
PHP: Obviously you'll need more than the code below, but the brunt of the work will be done by returning entries from your database that start with the letters currently entered into the searchbox. You can figure out the rest.
$query = "Select distinct(x) from (y) where x like '(z)%'";
x = field, y = table, z = variable you sent via AJAX
That should be more than enough to build an updating searchbox.