Advertisement
Guest User

engine/mainEngine.php

a guest
Jul 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. class MainClass {
  3. private $mysqli;
  4.  
  5. public $headTitle, $bodyTitle, $currentYear, $page;
  6. public function __construct($page) {
  7. $this -> mysqli = new mysqli('localhost', '*user*', '*pass*', '*db*');
  8. if ($page == '')
  9. $page = 'index';
  10. $this -> page = $page;
  11. $this -> initMainDetails();
  12. }
  13. public function initMainDetails() {
  14. $row = $this -> mysqli -> query('SELECT * FROM `content` WHERE `page` = "' . $this -> page . '";') -> fetch_assoc();
  15. $this -> headTitle = $row['headtitle'];
  16. $this -> bodyTitle = $row['bodytitle'];
  17. $this -> currentYear = date('Y');
  18. }
  19. public function displayContent() {
  20. require_once 'content/' . $this -> page . '.php';
  21. }
  22. public function getCatalogue($category) {
  23. $res = '';
  24. $sql = $this -> mysqli -> query('SELECT `id`, `title`, `price`, `img` FROM `' . $category . '` ORDER BY `id` DESC;');
  25. //print_r($sql);
  26. while($row = $sql -> fetch_assoc()) {
  27. $res .= '<article class="product">';
  28. $res .= '<a href="productview?category=' . $category . '&id=' . $row['id'] . '">';
  29. $res .= '<img src="" />';
  30. $res .= '</a>';
  31. $res .= '<p>' . $row['title'] . '</p>';
  32. $res .= '<p>' . $row['price'] . '</p>';
  33. $res .= '</article>';
  34. }
  35. return $res;
  36. }
  37. }
  38. $mainClass = new MainClass(explode('/', $_SERVER['REQUEST_URI'])[1]);
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement