Using PHP drop down to select MySQL table data?

Hey guys, since I’ve been told to drop MS access and use MySQL for a website based database, I decided to try it out and have been making some good progress, however I’ve come to a halt when trying to create a PHP drop down that filters through my simple table.

My table consists of 3 columns; Id, FirstName, and LastName. I want the drop down menu to filter through last names, as I have created fake names using 2 of the same last names(John Doe, Tim Doe, Bob Doe, Jim Earl, Tom Earl, etc).

Basically, my goal is for the drop down to have 3 options; All (The default option and display, which shows all names), Doe (Only display names with LastName equal to Doe), and finally Earl(Only display names with LastName equal to Earl).

The most I could come up with currently, is a drop down that displays the values of “FirstName” from my table, but again, it’s not what I’m trying to do ;/

Here is the code currently;


<?php

//some code, connecting to database, etc

$result = mysql_query("SELECT * FROM names");

print "<p>Select A First Name: \
";
print "<select name=\\"Id\\" > \
";
while ($row = mysql_fetch_array($result)){
		$Id = $row['Id'];
		$FirstName = $row['FirstName'];
		print "<option value=$Id>$FirstName\
";
		}
print "</select>\
";
print "</p>\
";

mysql_close($con);
?>


I know that’s probably know where near how I’m suppose to code the drop down with submit values to search the table, but it’s the closest I could come up with using my current knowledge.

Any ideas?

Element

[COLOR=DarkGreen]Please do not cross post, you’ve already post it here. If the problem turns out to be on the database side that thread can be moved to the MySQL forum.

Thread Closed.[/COLOR]