Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3.  
  4. <head>
  5. <meta charset="utf-8">
  6. <title>zad</title>
  7. </head>
  8. <body>
  9. <form action="zadanie14_03.php" metho="GET">
  10. Podaj gatunek:<input type="text" name="gatunek">
  11. <input type="submit" value="wyślij form">
  12. </form>
  13.  
  14.  
  15.  
  16. <?php
  17. if(isset($_GET["gatunek"]) && $_GET["gatunek"]!="") {
  18. $serverName="localhost";
  19. $userName="root";
  20. $pass="";
  21. $dbName="bazavod";
  22. $conn=mysqli_connect($serverName,$userName,$pass,$dbName);
  23. if(!$conn){
  24. die("błąd połączenia z serwerem lub bazą danych".
  25. mysql_connect_error());
  26. }
  27. echo "połączenie z bazą jest ok<br>";
  28. $sql="select tytul,gatunek from filmy where gatunek='".$_GET["gatunek"]."';";
  29. $wynik=mysqli_query($conn,$sql);
  30. if ($wynik){
  31. echo"pytanie okej";
  32. //sprawdzamy czy jest cos wyswietlenia
  33. if(mysqli_num_rows($wynik)>0) {
  34.  
  35. echo"sa wiersze do wyswietlenia";
  36. $str="<table border=1>";
  37. while($row=mysqli_fetch_assoc($wynik))
  38. {
  39. $str.="<tr><td>".$row["gatunek"]." </td><td> ".$row["tytul"]." </td><td>";
  40. }
  41. $str.="</table>";
  42. echo $str;
  43. }
  44. else{
  45. echo"nie ma wierszy do wyswietlenia";
  46. }
  47.  
  48. }
  49. else{
  50. echo"blad w pytaniu!";
  51. }
  52. }
  53. else{
  54. echo"wprowadz dane do formularza";
  55. }
  56.  
  57. ?>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement