Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 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.  
  10.  
  11.  
  12.  
  13.  
  14. <?php
  15. $serverName="localhost";
  16. $userName="root";
  17. $pass="";
  18. $dbName="bazavod";
  19. $conn=mysqli_connect($serverName,$userName,$pass,$dbName);
  20. if(!$conn){
  21. die("błąd połączenia z serwerem lub bazą danych".
  22. mysql_connect_error());
  23. }
  24. echo "połączenie z bazą jest ok<br>";
  25. $sql="select gatunek,tytul from filmy where gatunek='familijny'";
  26. $wynik=mysqli_query($conn,$sql);
  27. if ($wynik){
  28. echo"pytanie okej";
  29. //sprawdzamy czy jest cos wyswietlenia
  30. if(mysqli_num_rows($wynik)>0) {
  31.  
  32. echo"sa wiersze do wyswietlenia";
  33. $str="<table border=1>";
  34. while($row=mysqli_fetch_assoc($wynik))
  35. {
  36. $str.="<tr><td>".$row["gatunek"]." </td><td> ".$row["tytul"]." </td><td>";
  37. }
  38. $str.="</table>";
  39. echo $str;
  40. }
  41. else{
  42. echo"nie ma wierszy do wyswietlenia";
  43. }
  44.  
  45. }
  46. else{
  47. echo"blad w pytaniu!";
  48. }
  49.  
  50.  
  51. ?>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement