#winery_visit.php April 30, 2002
#Adapted to new look Aug 2010
#View wineries to visit in Table using vino/wine, vino/region_table. Also see winery_form.html, insert_winery.php3
#
require("/usr/home/jrnetc/www/htdocs/php/login.inc");
$winery_region=$_GET["winery_region"];
#Local variables
$align = "align=left valign=top";
$region_id = $winery_region;
#Create TD
function write_td($align, $winery, $addr1, $addr2, $tel, $fax, $email, $web, $hours, $contact, $region)
{
echo ("
");
if (strlen($winery) > 1) {
echo ("$winery");
}
if (strlen($addr1) > 1) {
echo (" $addr1");
}
if (strlen($addr2) > 1) {
echo (" $addr2");
}
if (strlen($tel) > 1) {
echo (" Tel: $tel");
}
if (strlen($fax) > 1) {
echo (" Fax: $fax");
}
if (strlen($email) > 1) {
echo (" E-mail: $email");
}
if (strlen($web) > 1) {
echo (" Web: $web");
}
if (strlen($hours) > 1) {
echo (" Visiting hours: $hours");
}
if (strlen($contact) > 1) {
echo (" Contact: $contact");
}
echo (" | ");
}
#End write_td function
#SQL statement
$SQL = "SELECT * FROM winery, region_table WHERE
winery_region = '$winery_region'
and winery.winery_region = region_table.region_id";
#Connect to database, retrieve query results
@ $cid = mysql_pconnect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
mysql_select_db("$db");
# execute SQL statement
$result = mysql_query($SQL);
$result00 = mysql_query($SQL);
#Total number of "wineries"
$num_results = mysql_num_rows($result);
$output = mysql_fetch_array($result00);
$region = ($output["region_name"]);
$comments = ($output["region_comments"]);
#Display results in table, rows
echo ("$num_results $region Wineries to Visit
");
require ("tour.inc");
echo ("$comments");
echo ("");
echo ("");
#
for ($i=0; $i < $num_results; $i++)
{
$td_count = 0;
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
$winery = ($row["winery_name"]);
$addr1 = ($row["winery_dir1"]);
$addr2 = ($row["winery_dir2"]);
$tel = ($row["winery_tel"]);
$fax = ($row["winery_fax"]);
$email = ($row["winery_email"]);
$web = ($row["winery_web"]);
$hours = ($row["winery_hours"]);
$contact = ($row["winery_contact"]);
$region = ($row["region_name"]);
if ($td_count < 2)
{
write_td($align, $winery, $addr1, $addr2, $tel, $fax, $email, $web, $hours, $contact, $region);
$td_count++;
}
else
{
echo ("
");
write_td($align, $winery, $addr1, $addr2, $tel, $fax, $email, $web, $hours, $contact, $region);
$td_count = 1;
}
}
}
echo ("
");
?>