Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. include_once 'database.php';
  4.  
  5. class FORUM {
  6.  
  7. private $rows;
  8.  
  9. function __construct($DB_con)
  10. {
  11. $this->db = $DB_con;
  12. }
  13.  
  14. public function getColumn() {
  15. try {
  16. $query = $this->db->prepare("DESCRIBE threads");
  17. $query->execute();
  18. //retrieve the columns inside the table posts
  19. $this->rows = $query->fetchAll(PDO::FETCH_COLUMN);
  20. } catch(PDOException $e) {
  21. echo $e->getMessage();
  22. }
  23. }
  24.  
  25. public function setColumn() {
  26. //output the column values
  27. if(is_array($this->rows)) {
  28. foreach($this->rows as $row) {
  29. echo $row . "</br>";
  30. }
  31. } else {
  32. echo "This is not an array";
  33. }
  34. }
  35.  
  36. } //End forum class
  37.  
  38. $forum = new FORUM($DB_con);
  39. $forum->getcolumn();
  40. $forum->setColumn();
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement