populate list box with database results

hi experts.
i am making a system at uni for a health center charity.

i am doing a search box to retrieve patients from the users table.

what i have now is a way for a receptionist to search by:
 patients id or surname / date of birth

this is retrieving the patent record. the php code is working up to this point.

i am thinking it would be nice if i could populate a list box with the result or results from the search so the receptionist can click on one of the results to select it. the selected result will then be used later when i create the appointment creation part.

so is there a easy way of doing this thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Check if the following code helps you.
function show_list_items($mySQL="", $selectname="noname", $firstitemname="", $selectid=0, $parameters="")
	echo "<select name=\"".$selectname."\"  class='textbox' id=\"".$selectname."\" ".$parameters.">\n";
	if ($firstitemname != '') echo "<option value=\"0\">".$firstitemname."</option>\n";
	if ($mySQL != '' )
		$rsSelect = mysql_query($mySQL);
		if($rsSelect) {
			$rowcnt = 0;
			while ($options = mysql_fetch_array($rsSelect)) 
				if ($options['0'] == $selectid) 
					echo "<option value=\"".$options['0']."\" SELECTED>".ucwords(trim($options['1']))."</option>\n";
				} else {
					echo "<option value=\"".$options['0']."\">".ucwords(trim($options['1']))."</option>\n";
	echo "</select>\n";

$mySQL = "SELECT feilds FROM table_name ";

show_list_items($mySQL, 'name_of_the_selectbox', 'First Item');

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

I think you are searching for a populate list box when typing on the search box. You can try jquery to autocomplete widget to make the list populate.

It uses ajax option to get based on database results.

URL: http://docs.jquery.com/UI/Autocomplete 

I think it will be useful.
helpchrisplzAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.