Guest User

Untitled

a guest
Jun 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. <?php
  2.  
  3. $config = [
  4. $dbname = "mysql:host=localhost;dbname=chicken;",
  5. $login = "root",
  6. $password = "",
  7. ];
  8.  
  9. try {
  10. $db = new PDO(...$config);
  11. } catch (Exception $ex) {
  12. throw new Exception("Could not connect to DB");
  13. }
  14.  
  15. $sql = "SELECT * FROM users";
  16. $stmt = $db->query($sql);
  17.  
  18. $result = $stmt->fetchAll();
  19.  
  20. foreach($result as $row){
  21. echo "username: " . $row['username'] . "<br>";
  22. echo "password: " . $row['password'] . "<br>";
  23. }
  24.  
  25. ?>
Add Comment
Please, Sign In to add comment