Advertisement
pan7nikt

Sportowcy_index

Jan 9th, 2022
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Sportowcy</title>
  8.     <link rel="stylesheet" type="text/css" href="styl.css">
  9. </head>
  10. <body>
  11.  
  12.     <div id="baner">
  13.         <h1>Klub sportowy: biegi kobiet na 100m</h1>
  14.     </div>
  15.     <div id="glowny">
  16.         <?php
  17.         $idSportowca = 1;
  18.         $conn = mysqli_connect('localhost','administrator','1357','sportowcy');
  19.         mysqli_query($conn,"SET CHARSET utf8");
  20.         $q = mysqli_query($conn, 'SELECT AVG(wynik) as sr FROM wyniki WHERE dyscyplina_id=1');
  21.         $q1 = mysqli_query($conn, 'SELECT COUNT(*) as rekordy FROM sportowiec');
  22.         $a1 = mysqli_fetch_array($q);
  23.         $a2 = mysqli_fetch_array($q1);
  24.         echo "<h1>Sredni wynik naszych biegaczek: ".$a1['sr']." s</h1>";
  25.  
  26.         echo "<table>";
  27.         for($i = 0; $i<$a2['rekordy']/3; $i++)
  28.         {
  29.             echo "<tr>";
  30.             for($j = 0; $j<3; $j++)
  31.             {
  32.                 $q = mysqli_query($conn, 'SELECT imie as imie,nazwisko as nazwisko FROM sportowiec WHERE id='.$idSportowca.'');
  33.                 $q1 = mysqli_query($conn, 'SELECT wynik as wynik FROM wyniki WHERE sportowiec_id='.$idSportowca.' AND dyscyplina_id=1 ORDER BY wynik ASC');
  34.  
  35.                 $a = mysqli_fetch_array($q);
  36.                 $a1 = mysqli_fetch_array($q1);
  37.                 echo
  38.                 "<td>
  39.                <h3>".$a['imie']." ".$a['nazwisko']."</h3>
  40.                <p>Najlepszy wynik: ".$a1['wynik']."</p>
  41.                </td>";
  42.                 $idSportowca++;
  43.             }
  44.             echo "</tr>";
  45.         }
  46.         echo "</table>";
  47.  
  48.         ?>
  49.     </div>
  50.     <div id="stopka">
  51.         <p>
  52.             Klub sportowy <br>
  53.             Stronę opracował: 12345678901
  54.         </p>
  55.     </div>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement