Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>
  6. PDO - nawiazanie polaczenia z baza danych
  7. </title>
  8. <style type="text/css">
  9. table {margin:auto; border:4px solid #cad0ff; background:#AC4574; width:50%;}
  10. table tr td, table tr th {background:#800; color:#fff; border:2px solid #008; text-align:center;}
  11. </style>
  12. </head>
  13. <body>
  14. <?php
  15. $polaczenie= new PDO('mysql:host=localhost;dbname=studenci2','root','');
  16. $polaczenie->query('SET NAMES utf8');
  17. $komunikat = $polaczenie->query('select d.id_studenta, d.imie, d.nazwisko, a.adres from dane d inner join adres a on d.adres_id=a.id_adresu');
  18. print('<table>');
  19. foreach ($komunikat as $wiersz)
  20. {
  21. echo('<tr><td> '. $wiersz['id_studenta'].'</td><td>'.$wiersz['imie']. '</td><td> '. $wiersz['nazwisko'].'</td><td> '. $wiersz['adres'].'</td></tr>');
  22. }
  23. print('</table>');
  24. ?>
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement