View Single Post
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: show club presidents info hide everyone else's

 
0
  #8
Aug 12th, 2008
I only found one type of thing wrong on this page, all of your
$zip = (isset($row['zip']) ? $row['zip'] : " ");
lines have an unmatched bracket ) on the end of them.
So I changed them to this
  1. $zip = ( isset($row['zip'] ) ? $row['zip'] : "&nbsp";
And played around with the rest of the code some too ... but no promises
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include( './config/db.php' );
  6.  
  7. $sub_name = $_GET['sub_name'];
  8.  
  9. $link = @mysql_connect( $server, $dbusername, $dbpassword ) or die(mysql_error());
  10.  
  11. $db = @mysql_select_db( $db_name ) or die(mysql_error());
  12.  
  13. /***
  14.  * Show publicly available data
  15.  ***/
  16. // Set up the roles that should be visible to the public
  17. $rolesToShow = array( "Master - President", "Overseer - Vice President", "Lecturer - Program Director", "Secretary" );
  18. $roles = "'".implode( "', '", $rolesToShow )."'";
  19.  
  20. // Create and execute the query
  21. $sql = "SELECT * FROM `MembersTable` WHERE sub_name='$sub_name' AND '$sub_office' IN($roles)";
  22.  
  23. $result = mysql_query( $sql ) or die( mysql_error() );
  24.  
  25. // Display the public data
  26. while( $row = mysql_fetch_row( $result ) ) {
  27. # Show data
  28. $fname = $row['fname'];
  29. $lname = $row['lname'];
  30. $sub_office = $row['sub_office'];
  31. $email = ( isset($row['email'] ) ? $row['email'] : "&nbsp;";
  32. $homephone = ( isset($row['homephone'] ) ? $row['homephone'] : "&nbsp;";
  33. $cellphone = ( isset($row['cellphone'] ) ? $row['cellphone'] : "&nbsp;";
  34. $address = ( isset($row['address'] ) ? $row['address'] : "&nbsp;";
  35. $city = ( isset($row['city'] ) ? $row['city'] : "&nbsp;";
  36. $state = ( isset($row['state'] ) ? $row['state'] : "&nbsp";
  37. $zip = ( isset($row['zip'] ) ? $row['zip'] : "&nbsp;";
  38. }
  39.  
  40. /***
  41.  * Show member specific data
  42.  ***/
  43. // Create the SQL query based on the user's status.
  44. if( $_SESSION['User']['status'] == 1 ) {
  45. $sql2 = "SELECT * FROM MembersTable WHERE sub_name = '$sub_name' AND '$sub_office' NOT IN($roles)";
  46. } else {
  47. $sql2 = "SELECT fname, lname, sub_office FROM MembersTable WHERE sub_name = '$sub_name' AND '$sub_office' NOT IN($roles)";
  48. }
  49.  
  50. // Execute the query and display the results
  51. $result2 = mysql_query( $sql2 ) or die( mysql_error() );
  52.  
  53. while ( $row = mysql_fetch_assoc( $result2 ) ) {
  54. // Set these based on whether the data was fetched or not
  55. // The (bool ? true : false) format is basically a compact if statement.
  56. $fname = $row['fname'];
  57. $lname = $row['lname'];
  58. $sub_office = $row['sub_office'];
  59. $email = ( isset($row['email'] ) ? $row['email'] : "&nbsp";
  60. $homephone = ( isset($row['homephone'] ) ? $row['homephone'] : "&nbsp";
  61. $cellphone = ( isset($row['cellphone'] ) ? $row['cellphone'] : "&nbsp";
  62. $address = ( isset($row['address'] ) ? $row['address'] : "&nbsp";
  63. $city = ( isset($row['city'] ) ? $row['city'] : "&nbsp";
  64. $state = ( isset($row['state'] ) ? $row['state'] : "&nbsp";
  65. $zip = ( isset($row['zip'] ) ? $row['zip'] : "&nbsp";
  66.  
  67. # Display data
  68. $display_block .= <<<ENDLINE
  69. <tr>
  70. <td>$sub_office</td>
  71. <td>$fname $lname</td>
  72. <td>$homephone / $cellphone</td>
  73. <td>$email</td>
  74. <td>$address, $city, $state $zip</td>
  75. <td>$sub_name</td>
  76. </tr>
  77. ENDLINE;
  78. }
  79.  
  80. $title = "<title>Officers of the $sub_name Subordinate Grange</title>";
  81. ?>
  82. <? include("./config/header.php"); ?>
  83. </head>
  84. <body>
  85. <table width="85%" border="1" class="main">
  86. <tbody>
  87. <tr>
  88. <td colspan="6"><h2>Officers of <? echo "$sub_name"; ?> Subordinate Grange</h2></td>
  89. </tr>
  90. <tr>
  91. <td><b>Office</b></td>
  92. <td><b>Officer</b></td>
  93. <td><b>Home / Cell Phone #</b></td>
  94. <td><b>Email</b></td>
  95. <td><b>Address</b></td>
  96. <td><b>Subordinate Grange</b></td>
  97. </tr>
  98. <? echo "$display_block"; ?>
  99. <tr>
  100. <td colspan="6"><!-- C. FOOTER AREA -->
  101. <div class="footer">
  102. <? include ('./config/footerinfo.php'); ?>
  103. </div></td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </body>
  108. </html>
Last edited by langsor; Aug 12th, 2008 at 7:22 pm.
Reply With Quote