Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. <head>
  2. <!-- Optional theme -->
  3. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"><link rel="stylesheet" href="style.css">
  4. </head>
  5. <body>
  6. <div class="container">
  7. <form method="get">
  8. <label>Wpisz nazwisko</label>
  9. <input type="text" name="nazwisko" placeholder="nazwisko">
  10. <button class="btn btn-primary" type="submit" value="szukaj">Szukaj</button>
  11. </form>
  12.  
  13.  
  14. <?php
  15.  
  16.  
  17. $Host='127.0.0.1';
  18. $DBase='oswiata';
  19. $FUser='root';
  20. $FPass='';
  21.  
  22.  
  23. function polacz( $host,$dbase,$user, $pass )
  24. {
  25. @$pol=mysqli_connect( $host, $user, $pass );
  26. if( !$pol )
  27. {
  28.  
  29. echo 'Bład polaczenia z Serwerem Bazy Danych'.PHP_EOL;
  30. echo "Kod błędu: " . mysqli_connect_errno() . PHP_EOL;
  31. echo "Błąd: " . mysqli_connect_error() . PHP_EOL;
  32. exit;
  33. }
  34. else
  35. {
  36. mysqli_select_db( $pol, $dbase );
  37. if( mysql_errno() )
  38. {
  39. echo mysql_errno();
  40. echo mysql_error();
  41. exit;
  42. }
  43. }
  44. return $pol;
  45. }
  46.  
  47. $idpol=polacz($Host, $DBase, $FUser, $FPass);
  48.  
  49.  
  50. if(isset($_GET['nazwisko'])){
  51. $wyniki=mysqli_query($idpol, "SELECT * FROM studenci WHERE nazwisko like '".$_GET['nazwisko']."'");
  52.  
  53. ?>
  54. <div class="table">
  55. <table class="table">
  56. <thead class="thead-dark">
  57. <tr>
  58. <th>NR_STUD</th>
  59. <th>NAZWISKO</th>
  60. <th>DATA_UR</th>
  61. <th>PLEC</th>
  62. <th>NR_KIER</th>
  63. </tr>
  64. </thead>
  65. <tbody>
  66. <?php
  67. if( $wyniki )
  68. {
  69. $color = 100;
  70. while($wiersz=mysqli_fetch_row($wyniki))
  71. {
  72. echo "<tr style='background-color: hsl($color, 100%, 70%)'>";
  73.  
  74. echo "<td>$wiersz[0]</td>";
  75. echo "<td><a href='testPN.php?student=$wiersz[0]' class=\"text-dark\">$wiersz[1]</a></td>";
  76. echo "<td>$wiersz[2]</td>";
  77. echo "<td>$wiersz[3]</td>";
  78. echo "<td>$wiersz[4]</td>";
  79. echo "</tr>";
  80. $color += 5;
  81. }
  82. echo "</tbody></table>";
  83. }
  84. else
  85. echo "Brak";
  86. }
  87.  
  88.  
  89. if(isset($_GET['student'])){
  90. $wyniki=mysqli_query($idpol, "SELECT * FROM oceny WHERE NR_STUD=".$_GET['student']);
  91. ?>
  92. <table class="table">
  93. <thead class="thead-dark">
  94. <tr>
  95. <th>NR_STUD</th>
  96. <th>NR_PRZEDM</th>
  97. <th>DATA_ZAL</th>
  98. <th>TERMIN</th>
  99. <th>ZAL_EGZ</th>
  100. <th>OCENA</th>
  101. </tr>
  102. </thead>
  103. <tbody>
  104. <?php if( $wyniki )
  105. {
  106. $color = 100;
  107. while($wiersz=mysqli_fetch_row($wyniki))
  108. {
  109. echo "<tr style='background-color: hsl($color, 100%, 70%)'>";
  110. echo "<td>$wiersz[0]</td>";
  111. echo "<td>$wiersz[1]</td>";
  112. echo "<td>$wiersz[2]</td>";
  113. echo "<td>$wiersz[3]</td>";
  114. echo "<td>$wiersz[4]</td>";
  115. echo "<td>$wiersz[5]</td>";
  116. echo "</tr>";
  117. $color += 30;
  118. }
  119. echo "</tbody></table>";
  120. }
  121. }
  122. ?>
  123.  
  124. </div>
  125. </div>
  126. <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  127. <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  128. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  129. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement