<?php
session_start();
include( './config/db.php' );
$sub_name = $_GET['sub_name'];
$link = @mysql_connect( $server, $dbusername, $dbpassword ) or die(mysql_error());
$db = @mysql_select_db( $db_name ) or die(mysql_error());
/***
* Show publicly available data
***/
// Set up the roles that should be visible to the public
$rolesToShow = array( "Master - President", "Overseer - Vice President", "Lecturer - Program Director", "Secretary" );
$roles = "'".implode( "', '", $rolesToShow )."'";
// Create and execute the query
$sql = "SELECT * FROM `MembersTable` WHERE sub_name='$sub_name' AND '$sub_office' IN($roles)";
$result = mysql_query( $sql ) or die( mysql_error() );
// Display the public data
while( $row = mysql_fetch_row( $result ) ) {
# Show data
$fname = $row['fname'];
$lname = $row['lname'];
$sub_office = $row['sub_office'];
$email = ( isset($row['email'] ) ? $row['email'] : " ";
$homephone = ( isset($row['homephone'] ) ? $row['homephone'] : " ";
$cellphone = ( isset($row['cellphone'] ) ? $row['cellphone'] : " ";
$address = ( isset($row['address'] ) ? $row['address'] : " ";
$city = ( isset($row['city'] ) ? $row['city'] : " ";
$state = ( isset($row['state'] ) ? $row['state'] : " ";
$zip = ( isset($row['zip'] ) ? $row['zip'] : " ";
}
/***
* Show member specific data
***/
// Create the SQL query based on the user's status.
if( $_SESSION['User']['status'] == 1 ) {
$sql2 = "SELECT * FROM MembersTable WHERE sub_name = '$sub_name' AND '$sub_office' NOT IN($roles)";
} else {
$sql2 = "SELECT fname, lname, sub_office FROM MembersTable WHERE sub_name = '$sub_name' AND '$sub_office' NOT IN($roles)";
}
// Execute the query and display the results
$result2 = mysql_query( $sql2 ) or die( mysql_error() );
while ( $row = mysql_fetch_assoc( $result2 ) ) {
// Set these based on whether the data was fetched or not
// The (bool ? true : false) format is basically a compact if statement.
$fname = $row['fname'];
$lname = $row['lname'];
$sub_office = $row['sub_office'];
$email = ( isset($row['email'] ) ? $row['email'] : " ";
$homephone = ( isset($row['homephone'] ) ? $row['homephone'] : " ";
$cellphone = ( isset($row['cellphone'] ) ? $row['cellphone'] : " ";
$address = ( isset($row['address'] ) ? $row['address'] : " ";
$city = ( isset($row['city'] ) ? $row['city'] : " ";
$state = ( isset($row['state'] ) ? $row['state'] : " ";
$zip = ( isset($row['zip'] ) ? $row['zip'] : " ";
# Display data
$display_block .= <<<ENDLINE
<tr>
<td>$sub_office</td>
<td>$fname $lname</td>
<td>$homephone / $cellphone</td>
<td>$email</td>
<td>$address, $city, $state $zip</td>
<td>$sub_name</td>
</tr>
ENDLINE;
}
$title = "<title>Officers of the $sub_name Subordinate Grange</title>";
?>
<? include("./config/header.php"); ?>
</head>
<body>
<table width="85%" border="1" class="main">
<tbody>
<tr>
<td colspan="6"><h2>Officers of <? echo "$sub_name"; ?> Subordinate Grange</h2></td>
</tr>
<tr>
<td><b>Office</b></td>
<td><b>Officer</b></td>
<td><b>Home / Cell Phone #</b></td>
<td><b>Email</b></td>
<td><b>Address</b></td>
<td><b>Subordinate Grange</b></td>
</tr>
<? echo "$display_block"; ?>
<tr>
<td colspan="6"><!-- C. FOOTER AREA -->
<div class="footer">
<? include ('./config/footerinfo.php'); ?>
</div></td>
</tr>
</tbody>
</table>
</body>
</html>