Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <meta charset="utf-8">
- <title>zad</title>
- </head>
- <body>
- <form action="zadanie14_03.php" metho="GET">
- Podaj gatunek:<input type="text" name="gatunek">
- <input type="submit" value="wyślij form">
- </form>
- <?php
- if(isset($_GET["gatunek"]) && $_GET["gatunek"]!="") {
- $serverName="localhost";
- $userName="root";
- $pass="";
- $dbName="bazavod";
- $conn=mysqli_connect($serverName,$userName,$pass,$dbName);
- if(!$conn){
- die("błąd połączenia z serwerem lub bazą danych".
- mysql_connect_error());
- }
- echo "połączenie z bazą jest ok<br>";
- $sql="select tytul,gatunek from filmy where gatunek='".$_GET["gatunek"]."';";
- $wynik=mysqli_query($conn,$sql);
- if ($wynik){
- echo"pytanie okej";
- //sprawdzamy czy jest cos wyswietlenia
- if(mysqli_num_rows($wynik)>0) {
- echo"sa wiersze do wyswietlenia";
- $str="<table border=1>";
- while($row=mysqli_fetch_assoc($wynik))
- {
- $str.="<tr><td>".$row["gatunek"]." </td><td> ".$row["tytul"]." </td><td>";
- }
- $str.="</table>";
- echo $str;
- }
- else{
- echo"nie ma wierszy do wyswietlenia";
- }
- }
- else{
- echo"blad w pytaniu!";
- }
- }
- else{
- echo"wprowadz dane do formularza";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement