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

  • SEARCH
  • Home
  • 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 1046783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:12:01+00:00 2026-05-16T16:12:01+00:00

i have two classes (Database for queries over database) and News for manipulating articles.

  • 0

i have two classes (Database for queries over database) and News for manipulating articles. On index.php (could be any other page) i call News class, which calls Database class. Everything goes ok, until i have to display result on index.php.

Let’s say, i save result in $news in News class.
How should i retrieve that array in index.php (like return $this->news or something else??). And how to display?

Could someone help.

  • 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-05-16T16:12:01+00:00Added an answer on May 16, 2026 at 4:12 pm

    On index.php (could be any other page) i call News class, which calls Database class.

    You don’t “call classes”. You call methods of classes.

    Let’s say, i save result in $news in News class.

    I suppose you mean you have a field (also property in PHP) names news, as in:

    class News {
        private $news;
        /* ... */
    }
    

    How should i retrieve that array in index.php (like return $this->news or something else??)

    You could add a method in News that returned this array:

    class News {
        private $news;
        function retrieveNews() {
            /* query the DB and store the result in $this->news */
        }
        function getData() { return $this->news; }
    }
    

    Or you could make it public and access it directly through $newsObject->news (not recommended).

    And how to display?

    That depends on the structure of the data and how you want to display it.

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

Sidebar

Related Questions

I have two PHP classes. One is for connecting to the database, building queries,
I have two classes that represent two different database entities. Their relationship is 1:m
I have two classes Foo and Bar . The tables in the database look
I have two classes, one that inherits from the other. The base class is
I was wondering if you could help me out.. I have two classes, one
I have two classes in a database, and wish to set up a one
I have two classes, Database and User. In the Database class I have function
I have two classes. I want to map Class1 to a database table with
I have two classes, one uses selenium to browse the internet, and the other
I have two classes, one is Post and the other is Category, with a

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.