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 7408231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:52:40+00:00 2026-05-29T05:52:40+00:00

I can semi-conceptually get this, but I can’t wrap my head around the right

  • 0

I can semi-conceptually get this, but I can’t wrap my head around the right way to do it.

Specifically, an object that needs to do the following…

class Question {
  var $text;
  var $filters = array();
  var $banners = arrya(); //But this has to be within $filter somehow...
  ... //all getter and setter functions
}

Now I am going to query a database and get a bunch of data returned, say 4 columns.

QuestionText | Filter | Banner | Value

I want to end up with an object that looks like….

Object
  Questions
   ->Question 1
     ->Text = Question One
     ->Filters
        ->Filter1
           ->Name = Ontario
           Banners
             Banner 1
              ->Name = Male
              ->Value = 20
             Banner 2
              ->Name = Famales
              ->Value = 20
        ->Filter2
           ->Name = Quebec
           Banners
           Banners
             Banner 1
              ->Name = Male
              ->Value = 20
             Banner 2
              ->Name = Famales
              ->Value = 20
   ->Question 2
     ->Text = Question Two
     ->Filters
     ......
     .....
     ....
     ...

Because I can only read from the database row by row, I need to find a way to add each new banner and value inside the Question / Filter combination. Eventually I want to spit it out as a table where each banner is a column.

  • 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-29T05:52:42+00:00Added an answer on May 29, 2026 at 5:52 am

    Firstly, you will need three classes

    class Question {
       var $text;
       var $filters;
    }
    
    class Filter {
       var $name;
       var $banners;
    }
    
    class Banner {
       var $name;
       var $value;
    }
    

    Then you would start off by creating your questions and adding the filters and banners to them like so:

    $questions = array();
    $x = 0;
    $result = mysql_query("SELECT * FROM `questions`");
    while ($obj = mysql_fetch_object($result)) {
        $questions[$x] = new Question();
        $questions[$x]->text = $obj->text;
        $result2 = mysql_query("SELECT * FROM `filters` WHERE `question` = {$obj->id}");
        $questions[$x]->filters = array();
        $y = 0;
        while ($obj2 = mysql_fetch_object($result2)) {
            $questions[$x]->filters[$y] = new Filter();
            ...
            // and so on
            ...
            $y++;
        }
        $x++;
    }
    

    Hope that helps.

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

Sidebar

Related Questions

I'm making a custom control that can be dragged around and it is semi
I have a semi-working example that you can look at. This appears to work
I would guess this is a semi-common question but I can't find it in
I want to make a CAML query semi-smart - in that I can give
I'm looking for information extraction libraries where I can have semi structured information that
Hey, how can I make it so that there's basically just a semi transparent
I have some (semi) complex conditional formatting to do in Excel. I can get
I'm looking for a fast PRNG so that I can quickly create (semi)unique IDs
I have gotten this semi autogenerated code, but I am uncertain where the Post
This is missing a semi colon or curly bracket or something and I can't

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.