0) // if a matching record was found
{
$r = mysql_fetch_array($result); // break the result into an array in order to access individual attributes
$day1 = $r[day1]; // store the first day of the festival into $day1 variable
$day2 = $r[day2]; // store the second day of the festival into $day2 variable
$day3 = $r[day3]; // store the third day of the festival into $day3 variable
$day4 = $r[day4]; // store the fourth day of the festival into $day4 variable
$day5 = $r[day5]; // store the fifth day of the festival into $day5 variable
// one or more of these days (except day4 and day5) may be null. These cases are handled later. Day 4 and 5 are the main days of the festival. The number of days may vary from year to year but will always be 2 or more.
$query2 = "SELECT *
FROM `events`
WHERE year = '$selectYear'"; // query string to get the events for the current year specified
$result2 = mysql_query($query2); // perform query and store results in $results2 variable
$numFound2 = mysql_num_rows($result2); // get the number of records found
$i = 0; // counter, start at 0
$tot = 5; // the total number of days is 5
$firstDay = 0; // variable to store which day is the first to be visible on the web page (database holds valid entries)
$r2 = mysql_fetch_array($result2); // break results into an array
echo ""; // end the JavaScript
echo '
";
// print a div for each day in the festival
for ($i = 1; $i < 6; $i++)
{
echo "
";
if ($i == 1)
{
$query = "SELECT *
FROM `events`
WHERE day = '$day1' AND year = '$selectYear'";
$result = mysql_query($query);
$numFound = mysql_num_rows($result);
if ($numFound > 0)
{
echo ("Events for " . strftime("%A, %B %e, %Y",mktime(0,0,0,10,$day1,$selectYear)) . "
");
echo "
";
while ($r = mysql_fetch_array($result))
{
echo "";
// print the event title
echo "" . $r[event_title] . " ";
// if there is a specified location for this event, print it
if ($r[location] != "" && $r[location] != "Unassigned Location")
{
echo "Location: $r[location] ";
}
// if there is a start time for this event, print it
if ($r[start_time] != "" && $r[start_time] != "00:00" && $r[start_time] != "0:60" && $r[start_ampm] != "" && $r[start_ampm] != "MM" && $r[start_ampm] != "0")
{
if (substr($r[start_time],0,1) == "0")
{
echo "Start Time: " . substr($r[start_time],1) . " $r[start_ampm] ";
}
else
{
echo "Start Time: $r[start_time] $r[start_ampm] ";
}
}
// if there is an end time for this event, print it
if ($r[end_time] != "" && $r[end_time] != "00:00" && $r[end_time] != "0:60" && $r[end_ampm] != "" && $r[end_ampm] != "MM" && $r[end_ampm] != "0")
{
if (substr($r[end_time],0,1) == "0")
{
echo "End Time: " . substr($r[end_time],1) . " $r[end_ampm] ";
}
else
{
echo "End Time: $r[end_time] $r[end_ampm] ";
}
}
// if there is a description for this event, print it
if ($r[event_description] != "")
{
echo "Description:| | " . urldecode($r[event_description]) . " |
";
}
echo " |
";
}
echo "
";
}
else // else there are no events listed for this day
{
echo "

Currently, there are no Events scheduled for " . strftime("%A",mktime(0,0,0,10,$day1,$selectYear)) . ", October $day1, $selectYear.";
}
}
else if ($i == 2)
{
$query = "SELECT *
FROM `events`
WHERE day = '$day2' AND year = '$selectYear'
ORDER BY start_time, start_ampm asc"; // query string to get events on the second day of the specified year and sorted in ascending order by the time that the event starts
$result = mysql_query($query);
$numFound = mysql_num_rows($result);
if ($numFound > 0)
{
echo ("Events for " . strftime("%A, %B %e, %Y",mktime(0,0,0,10,$day2,$selectYear)) . "
");
echo "
";
while ($r = mysql_fetch_array($result))
{
echo "";
// print the event title
echo "" . $r[event_title] . " ";
// if there is a location specified for this event, print it
if ($r[location] != "" && $r[location] != "Unassigned Location")
{
echo "Location: $r[location] ";
}
// if there is a start time for this event, print it
if ($r[start_time] != "" && $r[start_time] != "00:00" && $r[start_time] != "0:60" && $r[start_ampm] != "" && $r[start_ampm] != "MM" && $r[start_ampm] != "0")
{
if (substr($r[start_time],0,1) == "0")
{
echo "Start Time: " . substr($r[start_time],1) . " $r[start_ampm] ";
}
else
{
echo "Start Time: $r[start_time] $r[start_ampm] ";
}
}
// if there is an end time for this event, print it
if ($r[end_time] != "" && $r[end_time] != "00:00" && $r[end_time] != "0:60" && $r[end_ampm] != "" && $r[end_ampm] != "MM" && $r[end_ampm] != "0")
{
if (substr($r[end_time],0,1) == "0")
{
echo "End Time: " . substr($r[end_time],1) . " $r[end_ampm] ";
}
else
{
echo "End Time: $r[end_time] $r[end_ampm] ";
}
}
// if there is a description for this event, print it
if ($r[event_description] != "")
{
echo "Description:
| | " . urldecode($r[event_description]) . " |
";
}
echo " |
";
}
echo "
";
}
else // else there are no events listed for this day, print an informative message
{
echo "

Currently, there are no Events scheduled for " . strftime("%A",mktime(0,0,0,10,$day2,$selectYear)) . ", October $day2, $selectYear.";
}
}
else if ($i == 3)
{
$query = "SELECT *
FROM `events`
WHERE day = '$day3' AND year = '$selectYear'";
$result = mysql_query($query);
$numFound = mysql_num_rows($result);
if ($numFound > 0)
{
echo ("Events for " . strftime("%A, %B %e, %Y",mktime(0,0,0,10,$day3,$selectYear)) . "
");
echo "
";
while ($r = mysql_fetch_array($result))
{
echo "";
// print the event title
echo "" . $r[event_title] . " ";
// if there is a specified location for this event, print it
if ($r[location] != "" && $r[location] != "Unassigned Location")
{
echo "Location: $r[location] ";
}
// if there is a start time specified for this event, print it
if ($r[start_time] != "" && $r[start_time] != "00:00" && $r[start_time] != "0:60" && $r[start_ampm] != "" && $r[start_ampm] != "MM" && $r[start_ampm] != "0")
{
if (substr($r[start_time],0,1) == "0")
{
echo "Start Time: " . substr($r[start_time],1) . " $r[start_ampm] ";
}
else
{
echo "Start Time: $r[start_time] $r[start_ampm] ";
}
}
// if there is an end time specified for this event, print it
if ($r[end_time] != "" && $r[end_time] != "00:00" && $r[end_time] != "0:60" && $r[end_ampm] != "" && $r[end_ampm] != "MM" && $r[end_ampm] != "0")
{
if (substr($r[end_time],0,1) == "0")
{
echo "End Time: " . substr($r[end_time],1) . " $r[end_ampm] ";
}
else
{
echo "End Time: $r[end_time] $r[end_ampm] ";
}
}
// if there is a specified event description for this event, print it
if ($r[event_description] != "")
{
echo "Description: " . urldecode($r[event_description]) . " ";
}
echo " |
";
}
echo "
";
}
else // else if there are no events listed for this day, print an informative message
{
echo "

Currently, there are no Events scheduled for " . strftime("%A",mktime(0,0,0,10,$day3,$selectYear)) . ", October $day3, $selectYear.";
}
}
else if ($i == 4)
{
$query = "SELECT *
FROM `events`
WHERE day = '$day4' AND year = '$selectYear'";
$result = mysql_query($query);
$numFound = mysql_num_rows($result);
if ($numFound > 0)
{
echo ("Events for " . strftime("%A, %B %e, %Y",mktime(0,0,0,10,$day4,$selectYear)) . "
");
echo "
";
while ($r = mysql_fetch_array($result))
{
echo "";
// print the event title
echo "" . $r[event_title] . " ";
// if there is a specified location, print it
if ($r[location] != "" && $r[location] != "Unassigned Location")
{
echo "Location: $r[location] ";
}
// if there is a specified start time, print it
if ($r[start_time] != "" && $r[start_time] != "00:00" && $r[start_time] != "0:60" && $r[start_ampm] != "" && $r[start_ampm] != "MM" && $r[start_ampm] != "0")
{
if (substr($r[start_time],0,1) == "0")
{
echo "Start Time: " . substr($r[start_time],1) . " $r[start_ampm] ";
}
else
{
echo "Start Time: $r[start_time] $r[start_ampm] ";
}
}
// if there is a specified end time, print it
if ($r[end_time] != "" && $r[end_time] != "00:00" && $r[end_time] != "0:60" && $r[end_ampm] != "" && $r[end_ampm] != "MM" && $r[end_ampm] != "0")
{
if (substr($r[end_time],0,1) == "0")
{
echo "End Time: " . substr($r[end_time],1) . " $r[end_ampm] ";
}
else
{
echo "End Time: $r[end_time] $r[end_ampm] ";
}
}
// if there is a specified description, print it
if ($r[event_description] != "")
{
echo "Description: " . urldecode($r[event_description]) . " ";
}
echo " |
";
}
echo "
";
}
else // else there are no events for this day, print an informative message
{
echo "

Currently, there are no Events scheduled for " . strftime("%A",mktime(0,0,0,10,$day4,$selectYear)) . ", October $day4, $selectYear.";
}
}
else if ($i == 5)
{
$query = "SELECT *
FROM `events`
WHERE day = '$day5' AND year = '$selectYear'";
$result = mysql_query($query);
$numFound = mysql_num_rows($result);
if ($numFound > 0)
{
echo ("Events for " . strftime("%A, %B %e, %Y",mktime(0,0,0,10,$day5,$selectYear)) . "
");
echo "
";
while ($r = mysql_fetch_array($result))
{
echo "";
// print the event title
echo "" . $r[event_title] . " ";
// if there is a specified location for this event, print it
if ($r[location] != "" && $r[location] != "Unassigned Location")
{
echo "Location: $r[location] ";
}
// if there is a specified start time for this event, print it
if ($r[start_time] != "" && $r[start_time] != "00:00" && $r[start_time] != "0:60" && $r[start_ampm] != "" && $r[start_ampm] != "MM" && $r[start_ampm] != "0")
{
if (substr($r[start_time],0,1) == "0")
{
echo "Start Time: " . substr($r[start_time],1) . " $r[start_ampm] ";
}
else
{
echo "Start Time: $r[start_time] $r[start_ampm] ";
}
}
// if there is a specified end time for this event, print it
if ($r[end_time] != "" && $r[end_time] != "00:00" && $r[end_time] != "0:60" && $r[end_ampm] != "" && $r[end_ampm] != "MM" && $r[end_ampm] != "0")
{
if (substr($r[end_time],0,1) == "0")
{
echo "End Time: " . substr($r[end_time],1) . " $r[end_ampm] ";
}
else
{
echo "End Time: $r[end_time] $r[end_ampm] ";
}
}
// if a description has been provided for this event, print it
if ($r[event_description] != "")
{
echo "Description: " . urldecode($r[event_description]) . " "; // print the description for the event
}
echo " |
"; // end the column and row
}
echo "
"; // end the table
}
else // else there are no events scheduled for this day
{
echo "

Currently, there are no Events scheduled for " . strftime("%A",mktime(0,0,0,10,$day5,$selectYear)) . ", October $day5, $selectYear.";
}
}
echo "
"; // end the div
}
if ($firstDay != 0)
{
echo ""; // end the JavaScript
}
}
else
{
echo "Currently, there are no Events for $selectYear"; // there are no events in the database for the specified year
}
}
else
{
echo "There is no information for $selectYear."; // there is no information in the database corresponding to the specified year
}
mysql_close($mysql_link); // close the database connection
?>