Advertisement
ashtin68

Untitled

Jan 31st, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. <link rel="stylesheet" href="http://teawithlucas.com/test/style2.css" type="text/css" media="all">
  2.  
  3. <div id='MDR'>
  4.  
  5. <?php
  6.  
  7. // gloabal variables
  8. $debug=FALSE;
  9.  
  10. function mysqlconnect($server, $user, $pass, $db) {
  11. global $debug; //pulling globals
  12. $link = mysqli_connect($server, $user, $pass, $db); // Establish link
  13. if (!$link) { // Check connection
  14. // There was a problem - display error
  15. echo "Error: Unable to connect to MySQL." . PHP_EOL;
  16. echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  17. echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
  18. return FALSE; // Problem return false
  19. } else { // Connection established
  20. if($debug){ // Debug info for connection
  21. echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
  22. echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
  23. }
  24. return $link; // Conected - return connection link
  25. }
  26. }
  27.  
  28. function mysqlclose($link) {
  29. global $debug; //pulling globals
  30. mysqli_close($link); //closing connection
  31. }
  32.  
  33. function myslquery($query, $link) {
  34. global $debug; //pulling globals
  35.  
  36. $result = mysqli_query($link,$query); //querying connection
  37.  
  38. if (NULL!==$result){ //checking result for NULL
  39. return $result;
  40. } else {
  41. return FALSE;
  42. }
  43. }
  44.  
  45. function divisioncall($Divi, $link) {
  46. global $debug; //pulling globals
  47. $pos_sc_con = array(array('DC', 'DV', 'TL', 'TM', 'Not Set', '??'), array('Commander', 'Vice', 'Team Leader', 'Memeber', 'Not Set', '??'));
  48. //Addoulous' sql query
  49. $query = "SELECT Y.MemberName
  50. ,Y.Team
  51. ,Y.Rank
  52. ,Y.Prefix
  53. ,Y.Position
  54. ,Y.member_id
  55. FROM (
  56. SELECT Z.*
  57. ,CASE WHEN Z.Position = 'DC' THEN 1 WHEN Z.Position = 'DV' THEN 2 WHEN Z.Position = 'TL' THEN 3 WHEN Z.Position = '2IC' THEN 4 WHEN Z.Position = 'TM' THEN 5 ELSE 6 END AS RankID
  58. FROM (
  59. SELECT A.member_id
  60. ,A.name AS MemberName
  61. ,A.member_title AS Title
  62. ,CASE WHEN C.g_title = 'Probation' THEN 'Probation' WHEN C.g_title = 'Away' THEN 'Away' ELSE B.field_18 END AS Division
  63. ,CASE WHEN B.field_39 IN ('DC','DV') THEN 'Leadership' WHEN C.g_title = 'Away' THEN 'Away' WHEN C.g_title = 'Probation' THEN 'Probation' WHEN B.field_39 IS NULL THEN 'Unassigned' WHEN B.field_39 = 'Not Set' THEN 'Unassigned' ELSE B.field_38 END AS Team
  64. ,C.g_title AS Rank
  65. ,CASE WHEN B.field_39 = 'HQ' THEN 'TM' ELSE B.field_39 END AS Position
  66. ,CASE WHEN C.g_title = 'Away' THEN '<span style=''color:#808080''>' ELSE C.prefix END AS prefix
  67. FROM dicore_members AS A
  68. LEFT JOIN dicore_pfields_content AS B ON B.member_id = A.member_id
  69. LEFT JOIN orig_digroups AS C ON C.g_id = A.member_group_id
  70. WHERE CASE WHEN C.g_title = 'Probation' THEN 'Probation' WHEN C.g_title = 'Away' THEN 'Away' ELSE B.field_18 END = '".$Divi."' AND C.g_title NOT IN ('Registered Guest','Elder')
  71. ) Z
  72. ) Y
  73. ORDER BY CASE WHEN Y.Team = 'Leadership' THEN 1 WHEN Y.Team = 'Team A' THEN 2 WHEN Y.Team = 'Team B' THEN 3 WHEN Y.Team = 'Team C' THEN 4 WHEN Y.Team = 'Team D' THEN 5 WHEN Y.Team = 'Team E' THEN 6 WHEN Y.Team = 'Team F' THEN 7 WHEN Y.Team = 'Casual A' THEN 8 WHEN Y.Team = 'Casual B' THEN 9 WHEN Y.Team = 'Casual C' THEN 10 WHEN Y.Team = 'Casual D' THEN 11 ELSE 12 END, Y.RankID";
  74.  
  75. $result = myslquery($query,$link); //Call custom function
  76. if (!$result){ //Check for query problem
  77. echo "Error Bad qury or something";
  78. exit; //Stop before causing error
  79. }
  80.  
  81. $rowcount=mysqli_num_rows($result); //Get number of records for query
  82.  
  83.  
  84.  
  85. echo "<div class='Divsion' id='".$Divi."'><div class='headerline'><div class='diviheader'><h2>".$Divi." (".$rowcount.") </h2></div>"; //Start Division and Header
  86.  
  87. $previousteam = "#newdiv";
  88. while($row = mysqli_fetch_assoc($result)){
  89. $Rank = $row['Rank']; $Team = $row['Team']; $Prefix = $row["Prefix"]; $MemberName = $row['MemberName']; $posSC = $row['Position']; $mbrid = $row['member_id']; //setting array to local variables (might remove in future)
  90. $position=str_replace($pos_sc_con[0], $pos_sc_con[1], $posSC);
  91. if ($position==""){
  92. $position='Null';
  93. }
  94.  
  95. if ($previousteam != $Team){ //Checking if this record is new team
  96. if ($previousteam != "#newdiv"){ //Checking if first record in array
  97. if ("Leadership" != $previousteam){ //Checking previous team was not leadership, if so end team
  98. echo "</ol></div>";
  99. } else { //If previous team leadership, end header and end leadership group
  100. echo "</ol></div></div>";
  101. }
  102. } else {
  103. if ("Leadership" != $Team){ //catching error incase of no leaders
  104. echo "</div>";
  105. }
  106. }
  107. if ("Leadership" != $Team){ //Checking not leadership, if so start new team
  108. echo "<div class='team team-".$Team."'><h3>".$Team."</h3><ol>";
  109. } else { //If leadership, if so start leadership group
  110. echo "<div class='leadership'><ol>";
  111. }
  112. }
  113.  
  114. echo "<li class='position-".$posSC."'><a href='http://forum.dmg-inc.com/profile/".$mbrid."-".$MemberName."/' target='_blank'>";
  115. if ($posSC=='DC' || $posSC=='DV' || $posSC=='TL' || $posSC=='2IC'){
  116. echo "<span style='color:#fff'>".$position.": </span>";
  117. }
  118. echo $Prefix." ".$MemberName."</span></b><span style='color:#ddd; font-size:10px'> [".$posSC."]</span></a></li>"; //Adding record
  119.  
  120. $previousteam = $Team;
  121. }
  122. echo "</ol></div></div><br>"; //End team and division
  123. }
  124.  
  125. $server="localhost"; $user="reader"; $pass="crupR2#U"; $db="diforum"; //Set server variables
  126.  
  127. $mainlink=mysqlconnect($server,$user,$pass,$db); //Connect to server
  128.  
  129. divisioncall("DI-I", $mainlink);
  130. divisioncall("DI-II", $mainlink);
  131. divisioncall("DI-III", $mainlink);
  132. divisioncall("DI-IV", $mainlink);
  133. divisioncall("DI-V", $mainlink);
  134. divisioncall("DI-VI", $mainlink);
  135. divisioncall("DI-VII", $mainlink);
  136. divisioncall("DI-VIII", $mainlink);
  137. divisioncall("DI-IX", $mainlink);
  138. divisioncall("DI-X", $mainlink);
  139. divisioncall("DI-XI", $mainlink);
  140. divisioncall("DI-XII", $mainlink);
  141. divisioncall("DI-Community", $mainlink);
  142. divisioncall("Away", $mainlink);
  143. divisioncall("Probation", $mainlink);
  144.  
  145. mysqlclose($mysqllink); //Close Server
  146. ?>
  147. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement