Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <?php
  9. $server = "localhost";
  10. $dbName = "czwartek";
  11. $user = "root";
  12. $pass = "1234";
  13. $id = 1;
  14. try{
  15. $conn = new PDO("mysql:host=$server;dbname=$dbName", $user, $pass);
  16. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  17. $zapytanie = $conn ->prepare("select p.* from pracownicy as p order by p.nazwisko asc, p.imie asc;");
  18. $zapytanie->execute();
  19. $rs = $zapytanie->fetchAll();
  20. for($r=0; $r < count($rs, 0); $r++){
  21. echo $rs[$r]['id']." ".$rs[$r]['nazwisko']." ".$rs[$r]['imie'] ."<br>";
  22. }
  23. if(count($rs, 0) === 0){
  24. echo "Brak danych do wyswietlenia ...";
  25. }else{
  26. echo "Koniec danych ...";
  27. }
  28.  
  29. $conn = null;
  30. }catch(PDOExeption $e){
  31. echo "Error: ".$e->getMessage()."<br>";
  32. }
  33. ?>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement