Advertisement
Guest User

Untitled

a guest
Jan 15th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.49 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5.     <meta charset="utf-8" />
  6.     <title>Tabela wyników gry</title>
  7.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  8.     <script type="text/javascript" src="scripts.js"></script>
  9.     <style>
  10.         table, th, td {
  11.             border: 1px solid black;
  12.             border-collapse: collapse;
  13.         }
  14.  
  15.         th, td {
  16.             padding: 5px;
  17.             text-align: left;
  18.         }
  19.  
  20.         table tr:nth-child(even) {
  21.             background-color: #eee;
  22.         }
  23.  
  24.         table tr:nth-child(odd) {
  25.             background-color: #fff;
  26.         }
  27.  
  28.         table th {
  29.             background-color: orange;
  30.             color: black;
  31.         }
  32.     </style>
  33. </head>
  34. <body>
  35.     <h2 align="center">Tabela wyników gry w kości</h2>
  36.     <form action="gra.php" method="post">
  37.         <center>
  38.             <br />
  39.         <h3>Podaj swój nick:</h3>
  40.         <br />
  41.         <input type="text" name="nazwagracza" maxlength="18" />
  42. <br />
  43. <br />
  44.             <input type="submit" value="Graj" />
  45.             <br />
  46.             <br />
  47.         </center>
  48.     </form>
  49.     <table align="center">
  50.         <tr>
  51.             <th>Nick</th>
  52.             <th>Wynik</th>
  53.             <th>Data</th>
  54.         </tr>
  55.         <?php
  56.        $servername = "mysql.cba.pl";
  57.        $username = "dizzzzed";
  58.        $password = "sloanphp123";
  59.        $dbname = "dizzzzed";
  60.  
  61.        // Create connection
  62.        $conn = mysqli_connect($servername, $username, $password, $dbname);
  63.        // Check connection
  64.        if (!$conn) {
  65.        die("Connection failed: " . mysqli_connect_error());
  66.        }
  67.  
  68.        $sql = "SELECT `ID`, `nick`, `wynik`, `data` FROM `tb_score` ORDER BY `wynik`  DESC";
  69.        $result = mysqli_query($conn, $sql);
  70.  
  71.        if (mysqli_num_rows($result) > 0) {
  72.         // output data of each row
  73.         while($row = mysqli_fetch_assoc($result)) {
  74.  
  75.         $ID=$row["ID"];
  76.  
  77.         echo "<tr>";
  78.             echo "<td>";
  79.                 echo $row['nick'];
  80.                 echo "</td>";
  81.  
  82.             echo "<td>";
  83.                 echo $row['wynik'];
  84.             echo "</td>";
  85.  
  86.             echo "<td>";
  87.                 echo $row['data'];
  88.                 echo "</td>";
  89.  
  90.             echo "</tr>";
  91.  
  92.         }
  93.         } else {
  94.         }
  95.  
  96.         mysqli_close($conn);
  97.         ?>
  98.  
  99.         <tr></tr>
  100.  
  101.     </table>
  102.  
  103. </body>
  104. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement