Advertisement
Guest User

Leper's Colony - Burn all mods edition

a guest
Jan 29th, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.48 KB | None | 0 0
  1. <?php
  2. $db = mysqli_connect("localhost","USERNAME","PASSWORD","sa");
  3. $sql = "SELECT * FROM measure";
  4.  
  5. switch ($_GET['sort_by']) {
  6.     case "mods":
  7.         $sql .= " ORDER BY mods";
  8.         break;
  9.     case "total":
  10.         $sql .= " ORDER BY total";
  11.         break;
  12.     case "auto":
  13.         $sql .= " ORDER BY autobans";
  14.         break;
  15.     case "bans":
  16.         $sql .= " ORDER BY bans";
  17.         break;
  18.     case "perma":
  19.         $sql .= " ORDER BY permabans";
  20.         break;
  21.     case "probate":
  22.         $sql .= " ORDER BY probations";
  23.         break;
  24.     default:
  25.         break;
  26. }
  27.  
  28. if ($_GET['sort_by'] != "")
  29. {
  30.     if ($_GET['desc'] == 1)
  31.     {
  32.         $sql .= " DESC";
  33.     }
  34. }
  35.  
  36. $result = mysqli_query($db,$sql);
  37.  
  38. ?>
  39. <html>
  40. <head>
  41. <title>Leper's Colony &bull; Burn all mods edition</title>
  42. <style type="text/css">
  43. .results
  44. {
  45.         margin-left: 4%;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <p class="results"><strong><?php echo mysqli_num_rows($result); ?></strong> horrible mods have made requests. Dammit!</p>
  51. <table>
  52.         <tr>
  53.                 <th><a href="?sort_by=mods">HORRIBLE MOD</a></th>
  54.                 <th><a href="?sort_by=total">TOTAL</a></th>
  55.                 <th><a href="?sort_by=auto">AUTOBANS</a></th>
  56.                 <th><a href="?sort_by=bans">BANS</a></th>
  57.                 <th><a href="?sort_by=perma">PERMABANS</a></th>
  58.                 <th><a href="?sort_by=probate">PROBATIONS</a></th>
  59.         </tr>
  60.         <tr>
  61.                 <th><a href="?sort_by=mods&desc=1">[DESCENDING]</a></th>
  62.                 <th><a href="?sort_by=total&desc=1">[DESCENDING]</a></th>
  63.                 <th><a href="?sort_by=auto&desc=1">[DESCENDING]</a></th>
  64.                 <th><a href="?sort_by=bans&desc=1">[DESCENDING]</a></th>
  65.                 <th><a href="?sort_by=perma&desc=1">[DESCENDING]</a></th>
  66.                 <th><a href="?sort_by=probate&desc=1">[DESCENDING]</a></th>
  67.         </tr>
  68. <?php
  69. // this creates a row of data for each row that exists (there's about ~302 as of Jan 24, 2014)
  70.         while($row = mysqli_fetch_assoc($result))
  71.         {
  72.                 extract($row);
  73.                 ?>
  74.                 <tr>
  75.                         <td><?php echo $row['mods']; ?></td>
  76.                         <td><?php echo $row['total']; ?></td>
  77.                         <td><?php echo $row['autobans']; ?></td>
  78.                         <td><?php echo $row['bans']; ?></td>
  79.                         <td><?php echo $row['permabans']; ?></td>
  80.                         <td><?php echo $row['probations']; ?></td>
  81.                 </tr>
  82.                 <?php
  83.         }
  84. ?>
  85. </table>
  86. </body>
  87. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement