Advertisement
patryk178

Untitled

Sep 26th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. body
  5. {
  6. margin: 0;
  7. padding: 0;
  8. }
  9.  
  10. #gora,#dol
  11. {
  12. height: 50%;
  13. }
  14.  
  15. #gora div, #dol div
  16. {
  17. width: 50%;
  18. height: 100%;
  19. float: left;
  20. }
  21.  
  22. #glewy,#dprawy
  23. {
  24. background-color: cornflowerblue;
  25. }
  26.  
  27. #gprawy,#dlewy
  28. {
  29. background-color: lightblue;
  30. }
  31.  
  32. table
  33. {
  34. margin: 20% auto;
  35. border-collapse: collapse;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="gora">
  41.  
  42. <div id="glewy">
  43. <form action="?a=w1" method="post">
  44. <?php
  45. $baza = mysqli_connect("localhost","root","","biblioteka");
  46. $pyt = mysqli_query($baza,"SELECT Wydawnictwo FROM ksiazki GROUP BY Wydawnictwo");
  47. while($r = mysqli_fetch_array($pyt))
  48. {
  49. echo '<input type="checkbox" name="w[]" value="'.$r[0].'">'.$r[0];
  50. }
  51. ?>
  52. <input type="submit">
  53. </form>
  54.  
  55. <ol>
  56. <?php
  57. if(isset($_GET['a']) && $_GET['a']=="w1")
  58. {
  59.  
  60. $or = "";
  61. for($i=0;$i<4;$i++)
  62. {
  63. @$or.="Wydawnictwo = '".$_POST['w'][$i]."'";
  64. if($i<3)$or.=" OR ";
  65. }
  66.  
  67.  
  68.  
  69.  
  70. $pyt1 = mysqli_query($baza,"SELECT tytul FROM ksiazki WHERE $or");
  71. while($r = mysqli_fetch_array($pyt1))
  72. {
  73. echo "<li>".$r[0]."</li>";
  74. }
  75. }
  76.  
  77. ?>
  78. </ol>
  79. </div>
  80.  
  81.  
  82. <div id="gprawy">
  83.  
  84. <table border=1>
  85. dddd
  86. <tr>
  87. <th>Imie</th>
  88. <th>Nazwisko</th>
  89. <th>Tytuł</th>
  90. </tr>
  91.  
  92. <?php
  93.  
  94. $pyt = mysqli_query($baza,"SELECT Imie,Nazwisko,Tytul FROM ksiazki,autorzy WHERE IDAutor=AutorID");
  95. while($r = mysqli_fetch_array($pyt))
  96. {
  97. echo "<tr><td>".$r[0]."</td><td>".$r[1]."</td><td>".$r[2]."</td></tr>";
  98. }
  99.  
  100. ?>
  101. </table>
  102.  
  103. </div>
  104. </div>
  105.  
  106. <div id="dol">
  107. <div id="dlewy">
  108. <form action="?a=dodaj" METHOD="POST">
  109. <input type="text" name="imie">
  110. <input type="text" name="nazwisko">
  111. <input type="submit">
  112. </form>
  113.  
  114. <?php
  115.  
  116. if(isset($_GET['a']) && $_GET['a']=="dodaj")
  117. {
  118. echo "ss";
  119. $imie = $_POST['imie'];
  120. $nazwisko = $_POST['nazwisko'];
  121. $spr = mysqli_query($baza,"SELECT * FROM autorzy WHERE imie='$imie' AND nazwisko='$nazwisko'");
  122. if(mysqli_num_rows($spr)==0)mysqli_query($baza,"INSERT INTO autorzy(imie,nazwisko) VALUES('$imie','$nazwisko')");
  123. }
  124.  
  125. ?>
  126.  
  127.  
  128. </div>
  129. <div id="dprawy">
  130. <form action="?a=usun" method="post">
  131. <input type="text" name="imie">
  132. <input type="text" name="nazwisko">
  133. <input type="submit">
  134. </form>
  135. <?php
  136.  
  137. if(isset($_GET['a']) && $_GET['a']=="usun")
  138. {
  139. $imie = $_POST['imie'];
  140. $nazwisko = $_POST['nazwisko'];
  141. mysqli_query($baza,"DELETE FROM autorzy WHERE imie='$imie' AND nazwisko='$nazwisko'");
  142. }
  143.  
  144. ?>
  145. </div>
  146. </div>
  147. </body>
  148. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement