Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <?php
- $server = "localhost";
- $dbName = "czwartek";
- $user = "root";
- $pass = "1234";
- $id = 1;
- try{
- $conn = new PDO("mysql:host=$server;dbname=$dbName", $user, $pass);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $zapytanie = $conn ->prepare("select p.* from pracownicy as p order by p.nazwisko asc, p.imie asc;");
- $zapytanie->execute();
- $rs = $zapytanie->fetchAll();
- for($r=0; $r < count($rs, 0); $r++){
- echo $rs[$r]['id']." ".$rs[$r]['nazwisko']." ".$rs[$r]['imie'] ."<br>";
- }
- if(count($rs, 0) === 0){
- echo "Brak danych do wyswietlenia ...";
- }else{
- echo "Koniec danych ...";
- }
- $conn = null;
- }catch(PDOExeption $e){
- echo "Error: ".$e->getMessage()."<br>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement