Guest User

Untitled

a guest
Apr 23rd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2. class db {
  3. /*** mysql hostname ***/
  4. var $hostname = 'localhost';
  5. /*** mysql username ***/
  6. var $username = 'root';
  7. /*** mysql password ***/
  8. var $password = '';
  9. var $dbh;
  10. var $connected = false;
  11. function __construct(){
  12.    
  13.    $this->dbh = new PDO("mysql:host=$this->hostname;dbname=legiontd", $this->username, $this->password);
  14.    $this->connected = true;
  15.  } 
  16.  
  17. function get_loop($query){
  18.         if ($this->connected==true){
  19. }
  20.     foreach ($this->dbh->query($query) as $row)
  21.       {
  22.         print $row['author'] .' -<br/> '. $row['title'] . '<br />';
  23.        }
  24.  
  25.     /*** close the database connection ***/
  26.     $dbh = null;
  27.     }
  28. }
  29.  
  30. ?>
Add Comment
Please, Sign In to add comment