Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>
- Nawiazywanie polaczenia z baza danych
- </title>
- <style type="text/css">
- table{border:1px solid #000; margin:auto;}
- table tr td{background:#cad0ff; border:1px dotted #222; padding:4px 20px;}
- </style>
- </head>
- <body>
- <?php
- $polaczenie = @new mysqli('127.0.0.1','root','','klasa');
- if (mysqli_connect_errno() != 0 ) //funkcja zwraca numer bledu, zwraca 0 gdy
- {
- echo '<p>Wystapil blad polaczenia: ' . mysqli_connect_error() . '</p>';
- }
- else
- {
- $polaczenie->query ('SET NAMES utf8'); //pl znaki
- $polaczenie->query ('SET CHARACTERS_SET utf8_unicode_ci'); //pl znaki
- $wynik = @$polaczenie->query("SELECT * FROM uczniowie");
- if ($wynik === false)
- {
- print('<p>Zapytanie nie zostało wykonane poprawnie!</p>');
- $polaczenie -> close();
- }
- else
- {
- print('<table><tr><th>ID</th><th>IMIĘ</th><th>NAZWISKO</th><th>DATA_UR</th></tr>');
- while (($lista=$wynik->fetch_assoc())!==null)
- {
- print('<tr><td>'.$lista['Id_ucznia']. '</td><td> '.$lista['Imię'].' </td><td> '.$lista['Nazwisko'].' </td><td> '.$lista['Data_ur'].'</td></tr> ');
- }
- print('</table>');
- $wynik->close();
- $polaczenie->close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement