Guest User

Untitled

a guest
Jul 10th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2.  
  3. class mysqli {
  4.  
  5. //The Mysqli Variable
  6. public $mysqli;
  7.  
  8. //Database Info
  9. private $db_host = 'Localhost';
  10. private $username = 'root';
  11. private $password = '';
  12. private $db_name = 'simpleForum';
  13.  
  14. function __construct(){
  15. $this->mysqli = new mysqli($this->db_host, $this->username, $this->password, $this->db_name);
  16. }
  17. }
  18.  
  19. class forum extends mysqli {
  20.  
  21. function buildIndex(){
  22. $sql = 'SELECT id, name, description FROM `boards`';
  23. $result = parent::$mysqli->query($sql) or die(parent::$mysqli->error);
  24.  
  25. if($result->num_rows > 0){
  26. while($row = $result->fetch_assoc()){
  27. echo '<ul>';
  28. echo '<li>'.$row['name'].'</li>';
  29.  
  30. $sql2 = 'SELECT id, bID, name, description FROM `forums` WHERE bID = \''.$row['id'].'\'';
  31. $result2 = parent::$mysqli->query($sql2) or die(parent::$mysqli->error);
  32.  
  33. if($result2->num_rows > 0){
  34. while($row2 = $result2->fetch_assoc()){
  35. echo '<ul>';
  36. echo '<li><a href="index.php?action=board&id='.$row2['id'].'">'.$row2['name'].'</a></li>';
  37. echo '</ul>';
  38. }
  39. }
  40. echo '</ul>';
  41. }
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment