Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>
- PDO - nawiazanie polaczenia z baza danych
- </title>
- <style type="text/css">
- table {margin:auto; border:4px solid #cad0ff; background:#AC4574; width:50%;}
- table tr td, table tr th {background:#800; color:#fff; border:2px solid #008; text-align:center;}
- </style>
- </head>
- <body>
- <?php
- $polaczenie= new PDO('mysql:host=localhost;dbname=studenci2','root','');
- $polaczenie->query('SET NAMES utf8');
- $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');
- print('<table>');
- foreach ($komunikat as $wiersz)
- {
- echo('<tr><td> '. $wiersz['id_studenta'].'</td><td>'.$wiersz['imie']. '</td><td> '. $wiersz['nazwisko'].'</td><td> '. $wiersz['adres'].'</td></tr>');
- }
- print('</table>');
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement