<?php
include( './config/db.php' );
$sub_name = $_GET['sub_name']; // If it's a form value, you probably want to use $_POST['sub_name'] with <form method="POST">
$officers = array( "Master - President", "Overseer - Vice President", "Secretery", "Lecturer - Program Director" ); // edit to suite your needs ...
session_start();
$session = ( $_SESSION['auth']['status'] == 1 ) ? TRUE : FALSE; // or ? ... ( $_SESSION['User']['status'] == 1 )
$link = @mysql_connect( $server, $dbusername, $dbpassword ) or die( mysql_error() );
@mysql_select_db( $db_name ) or die( mysql_error() );
// make sure these are the names of the fields in your database, change them in
// the $sql query `email` (etc) and the $obj->email values (bellow) if they are not ...
$sql = "SELECT `fname`, `lname`, `sub_office`, `email`, `homephone`, `cellphone`, `address`, `city`, `state`, `zip`,
(SELECT
CASE
WHEN `sub_office` = 'Master - President' THEN 1
WHEN `sub_office` = 'Overseer - Vice President' THEN 2
WHEN `sub_office` = 'Lecturer - Program Director' THEN 3
WHEN `sub_office` = 'Steward' THEN 4
WHEN `sub_office` = 'Assistant Steward' THEN 5
WHEN `sub_office` = 'Lady Assistant Steward' THEN 6
WHEN `sub_office` = 'Chaplain' THEN 7
WHEN `sub_office` = 'Treasurer' THEN 8
WHEN `sub_office` = 'Building Treasurer' THEN 9
WHEN `sub_office` = 'Secretary' THEN 10
WHEN `sub_office` = 'Gate Keeper' THEN 11
WHEN `sub_office` = 'Flora' THEN 12
WHEN `sub_office` = 'Pomona' THEN 13
WHEN `sub_office` = 'Ceres' THEN 14
WHEN `sub_office` = 'Executive Committee' THEN 15
WHEN `sub_office` = 'Pianist' THEN 16
WHEN `sub_office` = 'Leadership' THEN 17
WHEN `sub_office` = 'Membership' THEN 18
WHEN `sub_office` = 'Legislative' THEN 19
WHEN `sub_office` = 'Family Activities' THEN 20
WHEN `sub_office` = 'Community Service' THEN 21
WHEN `sub_office` = 'Fun Committee' THEN 22
ELSE 23
END) as sort
FROM `MembersTable` WHERE sub_name='$sub_name'
ORDER BY sort ASC";
// You can just use this, if thesse are all or most of the values in the table ...
// $sql = "SELECT * FROM `MembersTable` WHERE sub_name='$sub_name'";
$result = mysql_query( $sql ) or die( mysql_error() );
$html = '';
while ( $obj = mysql_fetch_object( $result ) ) {
$html .= <<<ENDHTML
<tr>
<td>$obj->sub_office</td>
<td>$obj->fname $obj->lname</td>
ENDHTML;
if ( $session || in_array( $obj->sub_office, $officers ) ) {
$html .=<<<ENDHTML
<td>$obj->homephone / $obj->cellphone</td>
<td>$obj->email</td>
<td>$obj->address, $obj->city, $obj->state $obj->zip</td>
<td>$obj->sub_name</td>
ENDHTML;
}
$html .= " <\tr>\n";
}
$title = "<title>Officers of the $sub_name Subordinate Grange</title>";
?>
<?php 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>
<?php print $html; ?>
<tr>
<td colspan="6"><!-- C. FOOTER AREA -->
<div class="footer">
<?php include ('./config/footerinfo.php'); ?>
</div></td>
</tr>
</tbody>
</table>
</body>
</html>