I'm new to all this:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Exploring Wines in a Winery</title>
</head>
<body bgcolor="white">
<form action="example.6-14e1.php" method="GET">
<?php
require 'db.php';
// selectDistinct() function shown in Example 6-9 goes here
require "example.6-9e1.php";
// Show all wines in a region in a <table>
function displayWineryList($connection,
$query,
$yearName)
{
// Run the query on the server
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Find out how many rows are available
$rowsFound = @ mysql_num_rows($result);
// If the query has results ...
if ($rowsFound > 0)
{
// ... print out a header
print "Wineries producing wines in the year of $yearName<br>". "<br>".
"<SELECT NAME=thing>";
// Fetch each of the query rows
$options="Winery";
while ($row = @ mysql_fetch_array($result))
{
$id=$row["id"];
$winery=$row["winery_name"];
$options.="<OPTION VALUE=\"$result\">".$winery;
// Print one row of results
print
"<OPTION VALUE=0>Choose
$options</OPTION>";
} // end while loop body
print "</SELECT>" ."<br>" ."<br>" ;
} // end if $rowsFound body
// Report how many rows were found
print "\n" . "\n" ."{$rowsFound} records found matching your criteria<br>";
} // end of function
// Connect to the MySQL server
if (!($connection = @ mysql_connect($hostName, $username, $password)))
die("Could not connect");
// Secure the user parameter $yearName
$yearName = mysqlclean($_GET, "yearName", 30, $connection);
if (!mysql_select_db($databaseName, $connection))
showerror();
// Start a query ...
$query = "SELECT DISTINCT winery_name
FROM winery, region, wine
WHERE winery.region_id = region.region_id
AND wine.winery_id = winery.winery_id";
// ... then, if the user has specified a region, add the regionName
// as an AND clause ...
if (isset($yearName) && $yearName != "All")
$query .= " AND year = \"{$yearName}\"";
// ... and then complete the query.
$query .= " ORDER BY winery_name";
// run the query and show the results
displayWineryList($connection, $query, $yearName) . "\n" ."\n";
?>
<input type="submit" value="Show Wines">
</form>
</body>
</html>