Hi,
I'm a newbie to PHP so forgive me if this is very simple. I've tried and tried to get this to work on my own to no avail.
I have a MySQL db with a table named 'example'. It has three columns or fields: 'name', 'birth' and 'death'.
I want to create an HTML form that has a search box and a drop down list that let's the user choose which field he/she will search on. i.e. They can choose to search for the name of a person, the year a person died or the year a person was born.
Can someone please point me to an example of how this would work? I was able to create a simple page that displayed the whole database listings with this code:
<?php include("dbconnect.php"); ?>
<h2>View Whole Database</h2>
<?php
$result = mysql_query("select * from "example");
if ($result)
{
while ($row = mysql_fetch_array($result))
{
print "<b>Name:</b>";
print $row["name"];
print "<br>\n";
print "<b>Birth:</b>";
print $row["birth"];
print "<br>\n";
print "<b>Death:</b>";
print $row["death"];
print "<br>\n";
print "<br>\n";
print "<br>\n";
}
mysql_free_result($result);
}
?>
But I have no idea how to create a frontend search form that would allow the user to "choose", from a dropdown list, which field he would like to search.
Thanks,
Joe