Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2. $connect=new mysqli('localhost','root','','ewidencja_rolna');
  3. echo '<form method="POST" action="#"><select name="gmina" placeholder="Gmina">';
  4. $gminas=$connect->query("SELECT DISTINCT powiat FROM mleczarnie");
  5. while($g=$gminas->fetch_assoc())
  6. {
  7. echo '<option value="'.$g['gmina'].'">'.$g['gmina'].'</option>';
  8. }
  9. echo '</select><br />
  10. <input type="submit" name="find" value="Wyszukaj"><br /></form>';
  11.  
  12. if(isset($_POST['find']))
  13. {
  14. $gmin=$_POST['gmina'];
  15. $search=$connect->query("SELECT * FROM mleczarnie WHERE gmina='$gmin'");
  16. echo '<form method="POST" action="#"><select name="fabryka" placeholder="Nazwa">';
  17. while($tab=$search->fetch_assoc())
  18. {
  19. echo '<option value="'.$tab['nazwa'].'">'.$tab['nazwa'].'</option>';
  20. }
  21. echo '</select><br /><input type="submit" name="szuk" value="Wyszukaj"><br /></form>';
  22. }
  23.  
  24. if(isset($_POST['szuk']))
  25. {
  26. $fabr=$_POST['fabryka'];
  27. $found=$connect->query("SELECT * FROM mleczarnie WHERE nazwa='$fabr'");
  28. while($tabela=$found->fetch_assoc())
  29. {
  30. echo $tabela['nazwa'].'<br />Właściciel: '.$tabela['wlasciciel'].'<br />Numer telefonu: '.$tabela['telefon'].'<br />Adres: '.$tabela['ulica'].' '.$tabela['miasto'].'<br />Gmina: '.$tabela['gmina'].'<br />Powiat'.$tabela['powiat'].'<br />Województwo: '.$tabela['wojewodztwo'].'<br />Produkcja mleka: '.$tabela['produkcja_mleka'].' litrów miesięcznie.<br />Ilość zwierzyny: '.$tabela['ilosc_zwierzyny'].' krów';
  31. }
  32. }
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement