Advertisement
Guest User

Untitled

a guest
May 7th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. <?PHP
  2. $host="";
  3. $username="";
  4. $password="";
  5. $database="";
  6.  
  7. mysql_connect($host,$username,$password);
  8. @mysql_select_db($database) or die( "Unable to select database");
  9. $fetch = mysql_query("SELECT * FROM users ORDER BY RANK ASC LIMIT 0, 20")or
  10. die(mysql_error());
  11.  
  12. $num=mysql_numrows($fetch);
  13.  
  14.  
  15. ?>
  16. <?PHP
  17. //check if the starting row variable was passed in the URL or not
  18. if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
  19.   //we give the value of the starting row to 0 because nothing was found in URL
  20.   $startrow = 0;
  21. //otherwise we take the value from the URL
  22. } else {
  23.   $startrow = (int)$_GET['startrow'];
  24. }
  25. ?>
  26. <?PHP
  27. //this part goes after the checking of the $_GET var
  28. $fetch = mysql_query("SELECT * FROM users ORDER BY RANK ASC LIMIT $startrow, 20")or
  29. die(mysql_error());
  30.  
  31. mysql_close();
  32. ?>
  33. <style type="text/css">
  34.             table.fancy {
  35.               margin: 1em 1em 1em 0;
  36.               background: whitesmoke;
  37.               border-collapse: collapse;
  38.             }
  39.             table.fancy tr:hover {
  40.                background: #CC0000 !important;
  41.             }
  42.             table.fancy th, table.fancy td {
  43.               border: 1px silver solid;
  44.               padding: 0.2em;
  45.             }
  46.             table.fancy th {
  47.               background: #990000;
  48.               text-align: left;
  49.             }
  50.             table.fancy caption {
  51.               margin-left: inherit;
  52.               margin-right: inherit;
  53.             }
  54. </style>
  55. <table class="fancy"><center>
  56. <tr>
  57.             <th width="25%"><center>Name</center></th>
  58.             <th width="15%"><center>SteamID</center></th>
  59.             <th width="25%"><center>Rank</center></th>
  60. </tr></center>
  61.  
  62. <?
  63. $i=0;
  64. while ($i < $num) {
  65.  
  66. $ID=mysql_result($fetch,$i,"ID");
  67. $NAME=mysql_result($fetch,$i,"NAME");
  68. $RANK=mysql_result($fetch,$i,"RANK");
  69. ?>
  70.  
  71. <tr>
  72.                         <td><font face="Arial, Helvetica, sans-serif"><center><? echo $NAME; ?></center></font></td>
  73.                         <td><font face="Arial, Helvetica, sans-serif"><center><? echo $ID; ?></center></font></td>
  74.                         <td><font face="Arial, Helvetica, sans-serif"><center><?
  75.                         if ( $RANK == 0 ){
  76.                             echo "<font color=\"red\"><b>Owner</b></font>";
  77.                         }
  78.                         elseif ( $RANK == 1 ){
  79.                             echo "<font color=\"orange\"><b>Super Administrator</b></font>";
  80.                         }
  81.                         elseif ( $RANK == 2 ){
  82.                             echo "<font color=\"green\"><b>Administrator</b></font>";
  83.                         }
  84.                         elseif ( $RANK == 3 ){
  85.                             echo "<font color=\"pink\"><b>Trial Administrator</b></font>";
  86.                         }
  87.                         elseif ( $RANK == 4 ){
  88.                             echo "<font color=\"blue\"><b>VIP</b></font>";
  89.                         }
  90.                         elseif ( $RANK == 5 ){
  91.                             echo "Registered User";
  92.                         } ?></center></td>
  93. </tr>
  94.  
  95. <?
  96. $i++;
  97. }
  98.  
  99.  
  100. echo "</table>";
  101. ?><center>
  102. <?PHP
  103. //now this is the link..
  104. echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+20).'">Next</a>';
  105. ?>
  106.  
  107. <?PHP
  108. $prev = $startrow - 20;
  109.  
  110. //only print a "Previous" link if a "Next" was clicked
  111. if ($prev >= 0)
  112.     echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
  113. ?></center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement