Advertisement
Guest User

Untitled

a guest
Apr 27th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class FORUM {
  2.  
  3. function __construct($DB_con)
  4. {
  5. $this->db = $DB_con;
  6. }
  7.  
  8. public function getSubject() {
  9. try {
  10. $query = $this->db->prepare("SELECT * FROM posts");
  11. $query->execute();
  12. //retrieve the columns inside the table posts
  13. $forumrows = $query->fetchAll(PDO::FETCH_ASSOC);
  14.  
  15. //Output each column Id with its Value
  16. foreach($forumrows as $forumrow) {
  17. foreach($forumrow as $key=>$value) {
  18. //echo the key and value.
  19. echo "{$key} = {$value}<br>";
  20. }
  21. }
  22.  
  23. } catch(PDOException $e) {
  24. echo $e->getMessage();
  25. }
  26. }
  27. }
  28.  
  29. $forum = new FORUM($DB_con);
  30. $forum->getSubject();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement