Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.37 KB | None | 0 0
  1. <h1>Igényelt karakterek listája</h1>
  2.  
  3. <table class="table" id="myTable2">
  4.     <?php
  5.         echo'<tr style = "border: 2px white solid;">';
  6.             echo '<th onclick="sortTable(0)">ID</th>';
  7.             echo '<th onclick="sortTable(1)">Dátum</th>';
  8.             echo '<th onclick="sortTable(2)">Játékos név</th>';
  9.             echo '<th onclick="sortTable(3)">UCP név</th>';
  10.             echo '<th onclick="sortTable(4)">IP cím</th>';
  11.             echo '<th onclick="sortTable(5)">Régió</th>';
  12.             echo '<th colspan="2">Döntés</th>';
  13.         echo '</tr>';
  14.  
  15.     $i=1;
  16.     $sql = "SELECT * FROM players WHERE active = 0";
  17.     $result = mysqli_query($GLOBALS["db"], $sql);
  18.     if( mysqli_num_rows($result) > 0){
  19.         while ($row = mysqli_fetch_assoc($result)){
  20.             echo '<tr>';
  21.                 echo '<td style="border-left: 2px white solid;">', $i,'</td>';
  22.                 echo '<td>', $row["last_login"],'</td>';
  23.                 echo '<td>', get_character_name_by_id($row["id"]),'</td>';
  24.                 echo '<td>', get_ucp_name_by_character($row["name"]), '</td>';
  25.                 echo '<td>', $row["last_ip"], '</td>';
  26.                 echo '<td><a href="http://ip-api.com/#', $row["last_ip"], '" style="text-decoration:underline;">', get_ip_countryCode($row["last_ip"]), '</a></td>';
  27.                 echo '<td><a href="?o=activator&id=', $row["id"], '&do=accept">Elfogad</a></td>';
  28.                 echo '<td style = "border-right: 2px white solid;"><a href="?o=activator&id=', $row["id"], '&do=reject">Elutasít</a></td>';
  29.             echo '</tr>';
  30.             $i++;
  31.         }
  32.     }
  33.     ?>
  34. </table>
  35.  
  36.  
  37. <?php
  38. if(isset($_GET["o"]) && $_GET["o"] != "")
  39. {
  40.     $o = $_GET["o"];
  41.     if(file_exists("inc/".$o.".php"))
  42.     {
  43.         include_once("inc/".$o.".php");
  44.     }
  45.     else
  46.     {
  47.         include_once "inc/404.php";
  48.     }
  49. }
  50. else
  51. {
  52.     include_once ("inc/main.php");
  53.  
  54. }
  55. ?>
  56.  
  57. <script>
  58.     function sortTable(n) {
  59.         var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
  60.         table = document.getElementById("myTable2");
  61.         switching = true;
  62.         // Set the sorting direction to ascending:
  63.         dir = "asc";
  64.         /* Make a loop that will continue until
  65.         no switching has been done: */
  66.         while (switching) {
  67.             // Start by saying: no switching is done:
  68.             switching = false;
  69.             rows = table.rows;
  70.             /* Loop through all table rows (except the
  71.             first, which contains table headers): */
  72.             for (i = 1; i < (rows.length - 1); i++) {
  73.                 // Start by saying there should be no switching:
  74.                 shouldSwitch = false;
  75.                 /* Get the two elements you want to compare,
  76.                 one from current row and one from the next: */
  77.                 x = rows[i].getElementsByTagName("TD")[n];
  78.                 y = rows[i + 1].getElementsByTagName("TD")[n];
  79.                 /* Check if the two rows should switch place,
  80.                 based on the direction, asc or desc: */
  81.                 if (dir == "asc") {
  82.                     if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
  83.                         // If so, mark as a switch and break the loop:
  84.                         shouldSwitch = true;
  85.                         break;
  86.                     }
  87.                 } else if (dir == "desc") {
  88.                     if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
  89.                         // If so, mark as a switch and break the loop:
  90.                         shouldSwitch = true;
  91.                         break;
  92.                     }
  93.                 }
  94.             }
  95.             if (shouldSwitch) {
  96.                 /* If a switch has been marked, make the switch
  97.                 and mark that a switch has been done: */
  98.                 rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
  99.                 switching = true;
  100.                 // Each time a switch is done, increase this count by 1:
  101.                 switchcount ++;
  102.             } else {
  103.                 /* If no switching has been done AND the direction is "asc",
  104.                 set the direction to "desc" and run the while loop again. */
  105.                 if (switchcount == 0 && dir == "asc") {
  106.                     dir = "desc";
  107.                     switching = true;
  108.                 }
  109.             }
  110.         }
  111.     }
  112. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement