Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:34:38+00:00 2026-06-04T20:34:38+00:00

Class to display different views for my blog. class SB_Display { public function __contruct()

  • 0

Class to display different views for my blog.

class SB_Display {

    public function __contruct() {
        include_once('settings/db.settings.php');

        $mysqli = new mysqli($SB_dbsettings['host'],$SB_dbsettings['user'],$SB_dbsettings['pass'],$SB_dbsettings['dbname']);
    }

    private function List_Display() {

        $VIEW = '';

        include_once('views/list.html.view.php');

        $sql = "SELECT * FROM sb_posts ORDER BY ID DESC LIMIT '$SETTINGS->maxposts'";
        $sql = $mysqli->real_escape_string($sql);
        $res = $mysqli->mysqli_query($sql);

        if($res->numrows > 0) {
        $res->data_seek(0);

            while ($row = $res->fetch_assoc()) {
                foreach($row as $key => $value) {
                $BLOG->$key = $value;
                $VIEW .= $HTML;
                }
            }
        } else {
            $VIEW .= 'No Posts To Display';
        } 

        return $VIEW;
    }


    private function Single_Display($id) {
        $VIEW = '';

        include_once('views/single.html.view.php');

        $sql = "SELECT * FROM sb_posts WHERE BID = '$id'";
        $sql = $mysqli->real_escape_string($sql);
        $res = $mysqli->mysqli_query($sql);
        $row = $res->fetch_assoc();

        foreach($row as $key => $value) {
            $BLOG->$key = $value;
        }

        $VIEW .= $HTML;

        return $VIEW;
    }


    private function Create_Display() {        
        include_once('views/create.html.view.php');
        return $HTML;
    }

    private function Edit_Display($id) {
        $VIEW = '';  

        $sql = "SELECT * FROM sb_posts WHERE BID = '$id'";
        $sql = $mysqli->real_escape_string($sql);
        $res = $mysqli->mysqli_query($sql);
        $row = $res->fetch_assoc();

        foreach($row as $key => $value) {
            $BLOG->$key = $value;
        }
        $BLOG->id = $id;
        $VIEW .= $HTML;

        return $VIEW;

    }


    public function SB_Get_Display($type,$id) {
        switch($type) {
         case 'list':
             $this->content = List_Display();
             return $this;
             break;
         case 'single':
             $this->content = Single_Display($id);
             return $this;
             break;
         case 'create':
             $this->content = Create_Display();
             return $this;
             break;
         case 'edit':
             $this->content = Edit_display($id);
             return $this;
             break;
        }
    }
}

When using this class in the following manner ..

$BODY = new SB_Display();
$BODY->SB_Get_Display('list','');

I get this error:

Fatal error: Call to undefined function List_Display()

I can’t figure out why. Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:34:39+00:00Added an answer on June 4, 2026 at 8:34 pm

    You need to use $this->function() instead of function() to call a method.

    On a side-note, your constructor function name is incorrect. It’s __contruct() but needs to be __construct() to be used as a constructor. Besides that, your indentation is horrible and makes the code hard to read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Hello @hello = hello def display puts @hello end end h = Hello.new
I am trying to display only selected items in list view. public class Mact
I have to display different views for mobile devices and I want to provide
I am using the Glyphs class to display text in a Windows Phone 7
I am trying to get all the images with class front and display their
I'm writing a class that extends a UIScrollView to display a large tiled image,
I would like to display a div id based on the class of an
I have added checkbox in display table using decorator class as shown in below
I have a class that uses priority queue to display 5 strings in ascending
I have the following code require 'test_helper' class ApplicationControllerTest < ActionController::TestCase test should display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.