Advertisement
Guest User

Untitled

a guest
Jun 1st, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. index.php
  2.  
  3. <!DOCTYPE HTML>
  4.  
  5. <html lang="pl">
  6. <head>
  7. <meta charset="UTF-8"/>
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
  9. <link href="style.css" rel="stylesheet" type="text/css"/>
  10.  
  11. </head>
  12. <body>
  13.  
  14. <h1>Lista ksiazek</h1>
  15.  
  16. <?php
  17.  
  18. include ('baza.php');
  19.  
  20. $tbl = $pdo->query ('SELECT * FROM `regal`');
  21.  
  22. echo '<table border="3pxl">';
  23. echo '<tr>';
  24.  
  25. echo '<th>Autor</th>';
  26. echo '<th>Tytul</th>';
  27. echo '<th>Recenzja</th>';
  28. echo '<th>Opcje</th>';
  29. echo '</tr>';
  30.  
  31.  
  32. foreach ($tbl ->fetchAll() as $value){
  33.  
  34. echo '<tr>';
  35.  
  36. echo '<td>' . $value[ 'autor' ] . '</td>';
  37. echo '<td>' . $value[ 'tytul' ] . '</td>';
  38. echo '<td>' . $value[ 'recenzja' ] . '</td>';
  39. echo '<td>' . $value[ 'id' ] . '</td>';
  40.  
  41.  
  42. echo '</tr>';
  43.  
  44. echo '</table>';
  45.  
  46.  
  47. }
  48.  
  49. ?>
  50.  
  51.  
  52. </body>
  53. </html>
  54.  
  55. baza.php
  56.  
  57. <?php
  58.  
  59. require_once "connect.php";
  60.  
  61. try{
  62.  
  63. $pdo = new PDO('mysql: host='.$host.'; dbname='.$db_name.';port='.$port, $db_user, $db_password );
  64.  
  65. $pdo->setAttribute( PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC );
  66.  
  67.  
  68. } catch(PDOException $e){
  69. echo 'Polaczenie nie moglo zostac utworzone <br/>';
  70. }
  71.  
  72.  
  73. ?>
  74.  
  75. connect.php
  76.  
  77. <?php
  78.  
  79. $host = "localhost";
  80. $db_user = "root";
  81. $db_password = "";
  82. $db_name = "ksiazki";
  83. $port="";
  84.  
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement