Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class mysqli {
- //The Mysqli Variable
- public $mysqli;
- //Database Info
- private $db_host = 'Localhost';
- private $username = 'root';
- private $password = '';
- private $db_name = 'simpleForum';
- function __construct(){
- $this->mysqli = new mysqli($this->db_host, $this->username, $this->password, $this->db_name);
- }
- }
- class forum extends mysqli {
- function buildIndex(){
- $sql = 'SELECT id, name, description FROM `boards`';
- $result = parent::$mysqli->query($sql) or die(parent::$mysqli->error);
- if($result->num_rows > 0){
- while($row = $result->fetch_assoc()){
- echo '<ul>';
- echo '<li>'.$row['name'].'</li>';
- $sql2 = 'SELECT id, bID, name, description FROM `forums` WHERE bID = \''.$row['id'].'\'';
- $result2 = parent::$mysqli->query($sql2) or die(parent::$mysqli->error);
- if($result2->num_rows > 0){
- while($row2 = $result2->fetch_assoc()){
- echo '<ul>';
- echo '<li><a href="index.php?action=board&id='.$row2['id'].'">'.$row2['name'].'</a></li>';
- echo '</ul>';
- }
- }
- echo '</ul>';
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment