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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:24:56+00:00 2026-06-02T22:24:56+00:00

What I’m trying to do is create an array that contains a list of

  • 0

What I’m trying to do is create an array that contains a list of the titles with the title name, id of the database row, then the names of the champion and contenders. For the values of the champion and contenders I’m needing to do an additional query to retrieve the roster name of the person. If the value was 0 for the champion it needs to add Vacant to the array for that spot and if its 0 for the contender then it uses TBD for the array. Here’s what I’m working with so for which includes the query and the print_r output.

My question is I”m not sure where/how I need to be running an additional query with those values of the champion and contenders for each of the titles.

    /**
     * Get titles champions
     *
     * @return  object/NULL
     */
    function getTitlesChampions()
    {      
        $this->db->select('titlesList.id');
        $this->db->select('titlesList.titleName');
        $this->db->select('titlesChampions.championID');
        $this->db->select('titlesChampions.contender1ID');
        $this->db->select('titlesChampions.contender2ID');
        $this->db->select('titlesChampions.contender3ID');
        $this->db->from('titlesChampions');
        $this->db->join('titlesList', 'titlesList.id = titlesChampions.titlesListID');
        $query = $this->db->get();  
        if ($query->num_rows() > 0) {
            echo "<pre>";
            print_r ($query->result());
            echo "</pre>";

        }                                    
    }

Array
(
[0] => stdClass Object
    (
        [id] => 1
        [titleName] => Undisputed Heavyweight Title
        [championID] => 1
        [contender1ID] => 1
        [contender2ID] => 1
        [contender3ID] => 1
    )

[1] => stdClass Object
    (
        [id] => 2
        [titleName] => Outlaw Title
        [championID] => 1
        [contender1ID] => 0
        [contender2ID] => 0
        [contender3ID] => 0
    )

[2] => stdClass Object
    (
        [id] => 3
        [titleName] => Tag Team Titles
        [championID] => 1
        [contender1ID] => 0
        [contender2ID] => 0
        [contender3ID] => 0
    )

)
  • 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-02T22:24:57+00:00Added an answer on June 2, 2026 at 10:24 pm

    Best practice is a set of additional joins and subqueries, but given the (assumed) state of your schema, having a secondary function might be easiest.

    For each result that is found, you will iterate through and assign a Name by calling getRosterName(). That function will return and add additional information to the Champions object.

    /**
     * Get titles champions
     *
     * @return  object/NULL
     */
    function getTitlesChampions()
    {
        $this->db->select('titlesList.id');
        $this->db->select('titlesList.titleName');
        $this->db->select('titlesChampions.championID');
        $this->db->select('titlesChampions.contender1ID');
        $this->db->select('titlesChampions.contender2ID');
        $this->db->select('titlesChampions.contender3ID');
        $this->db->from('titlesChampions');
        $this->db->join('titlesList', 'titlesList.id = titlesChampions.titlesListID');
        $query = $this->db->get();  
    
        if ($query->num_rows() > 0) {
    
            $result = query->result();
    
            foreach($result as $row)
            {
                // Iterate through
                $row->championName      =   $this->getRosterName($row->championID);
                $row->contender1Name    =   $this->getRosterName($row->contender2ID);
                $row->contender2Name    =   $this->getRosterName($row->contender2ID);
                $row->contender3Name    =   $this->getRosterName($row->contender3ID);
            }
    
            // Return it
            return $result;
    
        }
        return null;
    }
    
    /*
    
    /* Returns the name */
    function getRosterName($rosterId = null)
    {
    
        if($rosterId && $rosterID > 0)
        {
            $this->db->select('RosterName');
            $this->db->where('rosterId', $rosterId);
            $query = $this->db->get('roster'); // Or whatever your `roster` table is named.
            return $query->row()->firstName; // Or whatever the name is you want returned
        }
        return null;
    }
    

    I don’t know anything about your schema, so this is a shot in the dark.

    Good luck.

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

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping 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.