<% $area = 'member'; ### Sets the area so the *next* toobar knows what to highlight require("/www/5nr/inc/header.d"); ### Adds the header to the page and 'require's constants, etc. require("/www/5nr/inc/mainbar.d"); ### Adds the main horizontal tool at the top require("/www/5nr/inc/database.d"); ### Create a connection to the database ### Note that functions must be defined before they are called in PHP3 (which we currently are stuck with). This is not the case in PHP4. function print_course_card( $row ) { ### This function prints out the "course card" on the page; a table containing course info ### The $row argument is an associative array (hash) that contians the record from the 'mtcourse' table ### Normally you can do: ### $course_row_array = mysql_fetch_array( $mysql_result_handle, MYSQL_ASSOC ); ### print_course_card( $course_row_array ); ### Print the table HTML tag print ""; ### Table cell containing course location info print "\n"; ### Table cell containing misc course info print ""; ### Table cell containing course contact info print ""; ### Table cell containing course notes info ### This cell will only be visible if there are notes in the record if ($row["mt_note"]) { print "
Location:  "; if ($row["mt_location1"]) { print $row["mt_location1"] . "
\n"; } if ($row["mt_location2"]) { print $row["mt_location2"] . "
\n"; } if ($row["mt_location3"]) { print $row["mt_location3"] . "
\n"; } if ($row["mt_city"]) { print $row["mt_city"] . ", \n"; } if ($row["mt_state"]) { print $row["mt_state"] . " \n"; } if ($row["mt_zip"]) { print $row["mt_zip"] . "\n"; } print "
Course Info:  
"; if ($row["mt_date"]) { print ""; } if ($row["mt_time"]) { print ""; } if ($row["mt_regdate"]) { print ""; } if ($row["mt_duration"]) { print ""; } print "
Date:" . FixDate($row["mt_date"]) . "
Time:" . $row["mt_time"] . "
Registration:" . FixDate($row["mt_regdate"]) . "
Duration:" . $row["mt_duration"] . "
Contact Info:  "; if ($row["mt_contact1"]) { print $row["mt_contact1"] . "
\n"; } if ($row["mt_phone1"]) { print $row["mt_phone1"] . "
\n"; } if ($row["mt_email1"]) { print ''.$row["mt_email1"]."
\n"; } if ($row["mt_contact2"]) { print "
" . $row["mt_contact2"] . "
\n"; } if ($row["mt_phone2"]) { print $row["mt_phone2"] . "
\n"; } if ($row["mt_email2"]) { print ''.$row["mt_email2"]."
\n"; } print "
Notes:  "; } if ($row["mt_note"]) { print $row["mt_note"] . "
\n"; } ### Close the table print "
"; return( 1 ); ### Return 1 (true) just for kicks } function get_course_desc( $mtdesc_id ) { ### Get the 'coursedesc' info and return an associative array (hash) of the data ### Normally you can do: ### $description_data_array = get_course_desc( $some_course_row["mtdesc_id"] ); $desc_result = mysql_query( "SELECT * FROM mtdesc WHERE mtdesc_id = $mtdesc_id" ); $desc_number = mysql_numrows( $desc_result ); $desc_row = mysql_fetch_array( $desc_result, MYSQL_BOTH ); return( $desc_row ); } %>

<% ### If they want to see everything, show em! if ($step == "all") { $result = mysql_query( "SELECT * FROM mtcourse ORDER BY mt_date" ); print "

 

\n"; print "

All Member Training Courses\n"; print "
Courses are shown in date order
\n"; print "Back

\n"; while ($row = mysql_fetch_array( $result, MYSQL_ASSOC )) { if ($row["mtdesc_id"]) { $desc_row = get_course_desc( $row["mtdesc_id"] ); print "

\n"; $title = $desc_row["mtdesc_title"]; if ($desc_row["mtdesc_url"]) { $title = "" . $title . ""; } print "$title
\n"; print_course_card( $row ); print " 
\n"; }} require("/www/5nr/inc/footer.d"); print "\n"; exit; } if ((!$step) || ($step == 1)) { /* BEGIN STEP 1 */ %>Member Training Courses

Welcome to the Fifth Northern Region's Member Training Database. Here you will find information about the Member Training courses that are currently being offered in the 5th Northern Region (parts of Pennsylvania, New Jersey and Delaware) for residential or classroom opportunities.  These courses are not on-line Member Training courses.  Additional information and descriptions of the various courses can be found by accessing the [full description] that is listed with each course listing.<% ### First we get all mtdesc_id's that are present in the 'mtcourse' table $num_result = mysql_query( "SELECT DISTINCT(mtdesc_id) FROM mtcourse" ); $num_number = mysql_numrows( $num_result ); $i = 0; while ($i < $num_number) { if ($i == 0) { $list = mysql_result($num_result, $i, "mtdesc_id"); } else { $list = $list . "," . mysql_result($num_result, $i, "mtdesc_id"); } $i++; } /* Then we get all 'mtdesc' info for the mt_id's that are in use */ $query = "SELECT * FROM mtdesc WHERE mtdesc_id IN ($list) ORDER BY mtdesc_title ASC"; $result = mysql_query($query); $number = mysql_numrows($result); if ($number == 0) { print "

There is currently no active courses in the database.

\n"; print "

Please try again at a later date.

\n"; } else { print "

Select the course you are interested in:

\n"; %>
<% /* print these results to the screen in a nice format */ while ($row = mysql_fetch_array( $result, MYSQL_ASSOC )) { $desc = get_course_desc( $row["mtdesc_id"] ); print ""; print "" . $row["mtdesc_title"] . ""; print ""; if ( $desc["mtdesc_url"] ) { print "  [full description]"; } print "
"; print "" . $desc["mtdesc_desc"] . ""; print "
 
"; } %>
<% } print "

You may also view all courses currently in the database (long).

\n"; } elseif ($step == 2) { /* BEGIN STEP 2 */ $desc = get_course_desc( $course ); print "

Member Training Courses

"; print "

You have selected:

"; print "" . $desc["mtdesc_title"] . ""; if ($desc["mtdesc_url"]) { print " [full description]"; } if ($desc["mtdesc_desc"]) { print "
" . $desc["mtdesc_desc"] . ""; } print "

\n"; $count_query = "SELECT count(*) as count FROM mtcourse WHERE mtdesc_id = '$course'"; $count_result = mysql_query($count_query); $number = mysql_result($count_result,0,"count"); $query = "SELECT DISTINCT(mt_city), mt_state FROM mtcourse WHERE mtdesc_id = '$course' ORDER BY mt_state, mt_city ASC"; $result = mysql_query($query); if ($number == 1) { print "

There is one course matching your choice in the database

"; $mt_city = mysql_result($result,0,"mt_city"); $mt_state = mysql_result($result,0,"mt_state"); $one_query = "SELECT * FROM mtcourse WHERE mtdesc_id = '$course' AND mt_city = '$mt_city' AND mt_state = '$mt_state'"; $one_result = mysql_query($one_query); $one_number = mysql_numrows($one_result); $row = mysql_fetch_array( $one_result, MYSQL_ASSOC ); print_course_card( $row ); } elseif ($number > 1) { print "

There are $number courses matching your choice in the database

"; print "Select the location of your course choice.

\n"; while ($row = mysql_fetch_array( $result, MYSQL_ASSOC )) { print ""; if (($row["mt_city"]) && ($row["mt_state"])) { print $row["mt_city"] . ", " . $row["mt_state"] . "
\n"; } elseif (($row["mt_city"]) && (!$row["mt_state"])) { print $row["mt_city"] . "
\n"; } elseif ((!$row["mt_city"]) && ($row["mt_state"])) { print $row["mt_state"] . "
\n"; } } print "

"; } } elseif ($step == 3) { /* BEGIN STEP 3 */ $query = "SELECT * FROM mtcourse WHERE mtdesc_id = $course AND mt_city = '$city' AND mt_state = '$state' ORDER BY mt_date"; $result = mysql_query($query); $number = mysql_numrows($result); print "

Member Training Courses

"; print "

" . $title . " in "; if (($city) && ($state)) { print "$city, $state"; } elseif (($city) && (!$state)) { print $city; } elseif ((!$city) && ($state)) { print $state; } print ".

"; print "

---------------------

"; while ($course_row = mysql_fetch_array( $result, MYSQL_ASSOC )) { print "

Result #" . ($i + 1) . ":

"; print "

\n"; print_course_card( $course_row ); print "

\n"; $i++; if ($i < $number) { print "
---------------------
"; } } } if ($step >= 2) { print "

Start Over

"; } %>
<% require("/www/5nr/inc/footer.d"); %>