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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:58:46+00:00 2026-06-02T12:58:46+00:00

I’m having an issue with my array in the view file. What Im trying

  • 0

I’m having an issue with my array in the view file. What I”m trying to do is have it show the list of titles and and contenders for each title. As of right now its showing Vacant as the champion for each title AND TBD for each contender for each title when I have values that should be working but isn’t.

If the value for the championID is 0 in the table it should display Vacant if its not then it should get the champions name and display it. For each of the contenders if its a 0 in the database then it should display TBD if its not then it should display their name.

Here’s the query:

/**
 * Get title champions
 *
 * @return  object/NULL
 */
function getTitlesChampions()
{       
    $this->db->select('titlesList.titleName');
    $this->db->select('rosterList.rosterName AS champion');
    $this->db->select('con1.rosterName AS contender1');
    $this->db->select('con2.rosterName AS contender2');
    $this->db->select('con3.rosterName AS contender3');
    $this->db->from('titlesChampions');
    $this->db->join('titlesList', 'titlesList.id = titlesChampions.titlesListID');
    $this->db->join('rosterList', 'rosterList.id = titlesChampions.championID', 'left');
    $this->db->join('rosterList AS con1', 'con1.id = titlesChampions.contender1ID', 'left');
    $this->db->join('rosterList AS con2', 'con2.id = titlesChampions.contender2ID', 'left');
    $this->db->join('rosterList AS con3', 'con3.id = titlesChampions.contender3ID', 'left');
    $query = $this->db->get();
    if ($query->num_rows() > 0) 
    {
        return $query->result();
    }
    return null;
}

Values inside of the titlesChampions table is this:

id - 1  titlesListID - 1  championID - 1  contender1ID - 1   contender2ID - 1  contender3ID - 1
id - 2  titlesListID - 2  championID - 1  contender1ID - 0   contender2ID - 0  contender3ID - 0
id - 3  titlesListID - 3  championID - 1  contender1ID - 0   contender2ID - 0  contender3ID - 0

I run a print_r of the array in the view file and this is what prints out:

Array
(
[0] => stdClass Object
    (
        [titleName] => Undisputed Heavyweight Title
        [champion] => Kid Wonder
        [contender1] => Kid Wonder
        [contender2] => Kid Wonder
        [contender3] => Kid Wonder
    )

[1] => stdClass Object
    (
        [titleName] => Outlaw Title
        [champion] => Kid Wonder
        [contender1] => 
        [contender2] => 
        [contender3] => 
    )

[2] => stdClass Object
    (
        [titleName] => Tag Team Titles
        [champion] => Kid Wonder
        [contender1] => 
        [contender2] => 
        [contender3] => 
    )

)


    <?php if (!is_null($titlesChampionsList)) { foreach ($titlesChampionsList AS $champion) { 
                    echo '<tr>'; 
                    echo '<td>'.$champion->id.'</td>'; 
                    echo '<td>'.$champion->titleName.'</td>'; 
                    echo '<td>';
                    if ($champion->champion == 0)
                    {
                        echo 'Vacant';
                    }
                    else {
                        $champion->champion;
                    }
                    echo '</td>'; 
                    echo '<td>';
                    if ($champion->contender1 == 0)
                    {
                        echo 'TBD';
                    }
                    else {
                        $champion->contender1;
                    }
                    echo '</td>'; 
                    echo '<td>';
                    if ($champion->contender2 == 0)
                    {
                        echo 'TBD';
                    }
                    else {
                        $champion->contender2;
                    }
                    echo '</td>'; 
                    echo '<td>';
                    if ($champion->contender3 == 0)
                    {
                        echo 'TBD';
                    }
                    else {
                        $champion->contender3;
                    }
                    echo '</td>'; 
                    echo '<td style="text-align: center">'; 
                    $data = array('name' => 'user', 'value' => $champion->id); 
                    echo '<a href="bios/edituser"><img src='.base_url().'assets/img/icons/packs/fugue/24x24/plus-circle.png /></a>'; 
                    echo '<img src='.base_url().'assets/img/icons/packs/fugue/24x24/cross-circle.png id="delete"/>'; 
                    echo '</td>';
                    echo '</tr>
                    '; } } ?>

Any ideas?

  • 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-02T12:58:47+00:00Added an answer on June 2, 2026 at 12:58 pm

    Assuming that array is in fact what is returned from the function:

    foreach ($array as $key => $titleObject) {
        $champion = ($titleObject->champion ? $titleObject->champion : 'Vacant');
        echo $titleObject->titleName.' champion is '.$champion.'<br />';
        $contender1 = ($titleObject->contender1 ? $titleObject->contender1 : 'tbd');
        $contender2 = ($titleObject->contender2 ? $titleObject->contender2 : 'tbd');
        $contender3 = ($titleObject->contender3 ? $titleObject->contender3 : 'tbd');
        echo $titleObject->titleName.' contenders are '.$contender1.', '.$contender2.' and '.$contender3.'<br />';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.