Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MainClass {
- private $mysqli;
- public $headTitle, $bodyTitle, $currentYear, $page;
- public function __construct($page) {
- $this -> mysqli = new mysqli('localhost', '*user*', '*pass*', '*db*');
- if ($page == '')
- $page = 'index';
- $this -> page = $page;
- $this -> initMainDetails();
- }
- public function initMainDetails() {
- $row = $this -> mysqli -> query('SELECT * FROM `content` WHERE `page` = "' . $this -> page . '";') -> fetch_assoc();
- $this -> headTitle = $row['headtitle'];
- $this -> bodyTitle = $row['bodytitle'];
- $this -> currentYear = date('Y');
- }
- public function displayContent() {
- require_once 'content/' . $this -> page . '.php';
- }
- public function getCatalogue($category) {
- $res = '';
- $sql = $this -> mysqli -> query('SELECT `id`, `title`, `price`, `img` FROM `' . $category . '` ORDER BY `id` DESC;');
- //print_r($sql);
- while($row = $sql -> fetch_assoc()) {
- $res .= '<article class="product">';
- $res .= '<a href="productview?category=' . $category . '&id=' . $row['id'] . '">';
- $res .= '<img src="" />';
- $res .= '</a>';
- $res .= '<p>' . $row['title'] . '</p>';
- $res .= '<p>' . $row['price'] . '</p>';
- $res .= '</article>';
- }
- return $res;
- }
- }
- $mainClass = new MainClass(explode('/', $_SERVER['REQUEST_URI'])[1]);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement