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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:44:06+00:00 2026-05-26T08:44:06+00:00

What I need to happen is have the top5 variable array get used for

  • 0

What I need to happen is have the top5 variable array get used for my index page. As of right now it says its an undefined variable. So with the if statement that assigns the page variable it needs to know to send the top5 variable array with it IF its the index page its going to load. When I do a print_r of the top5 variable in the controller it shows up like this:

Array ( [0] => Array ( [character_name] => Kid Wonder ) [1] => Array ( [character_name] => Ryu Satoshi ) [2] => Array ( [character_name] => Oriel ) [3] => Array ( [character_name] => "The Ladies Man" Luscious Landon ) [4] => Array ( [character_name] => "The Outlaw" Mike Mayhem ) ) 

Controller:

$siteInfo = $this->site->getSiteTitleAndSlogan();
$activeTemplate = $this->site->getTemplate();
if ($this->site->pageStatus('index', $activeTemplate[0]->id) == 1){
    $page = $this->load->view($activeTemplate[0]->short_name.'/pages/index', '', true); 
} else {
    $page = $this->load->view($activeTemplate[0]->short_name.'/pages/404', '', true); 
}
$footerLinks = $this->site->getFooterNav(); 
$top5 = $this->site->getTop5(); 
print_r($top5);
$this->template
->title($siteInfo[0]->site_name,$siteInfo[0]->site_slogan)
->prepend_metadata('<link rel="stylesheet" type="text/css" href="http://www.kansasoutlawwrestling.com/assets/css/'.$activeTemplate[0]->short_name.'.css" />')
->set('footerLinks', $footerLinks)
->set('page', $page)
->set('top5', $top5)               
->set_partial('header', $activeTemplate[0]->short_name.'/header')
->set_partial('navigation', $activeTemplate[0]->short_name.'/navigation')            
->set_partial('content', $activeTemplate[0]->short_name.'/content')
->set_partial('footer', $activeTemplate[0]->short_name.'/footer')
->build('kow');

EDIT :

Here’s my template system.

/views
/views/kow.php (template file)
/views/v1 (current template version)/
/views/v1/header.php
/views/v1/footer.php
/views/v1/navigation.php
/views/v1/content.php
/views/v1/pages/
/views/v1/pages/index.php(homepage)
/views/v1/pages/404.php(error page)

Content View:

<div id="content">
    <?php 
    echo $page; 
    ?>
</div>

Index Page View:

<div id="left">

<div id="spotlight">
    <img id="spotlight" src="assets/images/spotlight.png" alt="Kansas Outlaw Wrestling" />
</div>

<div id="top5">
    <ol>
        <?php 
        for ($i = 0; $i >= count($top5); $i++){
            foreach($top5[$i] as $row)
            {
                $seperator = ($elements == $count) ? '' : '<hr />'; 
                $name = (!isset($row['character_name'])) ? 'TBD' : $row['character_name'];
                $count++;
            ?>
                <li><span class="red"><?php echo $name; ?></span></li>
            <?php
         }
        }
        ?>

    </ol>
</div>

</div>

<div id="middle">
    <div id="topnews">
        <img id="topnewspic" src="assets/images/kelly.png" alt="Top News Pic" valign="right" />
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet mauris et erat luctus faucibus. In hac habitasse platea dictumst. Nunc sollicitudin ultricies nisi vel blandit. Quisque tincidunt mattis lacinia. Maecenas porttitor magna eu velit hendrerit ornare. Donec ultrices porttitor tellus sed venenatis. Integer ipsum lacus, malesuada eget ornare vel, mollis vel metus. Fusce a orci sed dui accumsan luctus et id enim. Aenean ac dui orci. Nam fringilla rutrum libero eget laoreet. Mauris ac sem metus, a ultrices ante. Duis quam metus, rhoncus sed dictum vel, ultricies vel nibh. Pellentesque enim lorem, mollis ut lacinia ac, aliquet id magna. Proin ante sapien, molestie in tincidunt hendrerit, blandit ut dolor. In rhoncus convallis ullamcorper. Integer sed arcu vitae libero dapibus interdum.</p>
        <p>Sed nibh leo, consequat non tempor vitae, fringilla eget augue. Pellentesque libero turpis, lobortis euismod consectetur eu, ultrices non orci. Aliquam erat volutpat. Sed et nunc orci. Aliquam semper tortor in nunc placerat pulvinar. Etiam placerat ornare metus, id malesuada mi venenatis quis. Suspendisse dapibus, metus sollicitudin dictum aliquet, nisi dui tempus felis, a tristique sem est at ligula. Praesent commodo dolor ac ante ornare id cursus tellus luctus. Vivamus pretium metus ut dui hendrerit tincidunt.</p>
    </div>
</div>

<div id="right">

    <div id="upcomingevents">

        <ul>
            <li>Warpath<span class="red">October 31, 2011</span></li>
            <hr />
            <li>Warpath<span class="red">October 31, 2011</span></li>
            <hr />
            <li>Warpath<span class="red">October 31, 2011</span></li>
            <hr />
            <li>Warpath<span class="red">October 31, 2011</span></li>
            <hr />
            <li>Warpath<span class="red">October 31, 2011</span></li>
        </ul> 

    </div>

    <div id="poll">
        <p id="question" class="red">How is it coming along?</p>
    </div>  

</div>

EDIT 2 :

Controller:

$siteInfo = $this->site->getSiteTitleAndSlogan();
        $activeTemplate = $this->site->getTemplate();
        if ($this->site->pageStatus('index', $activeTemplate[0]->id) == 1){
            $page = $this->load->view($activeTemplate[0]->short_name.'/pages/index', '', true);  
        } else {
            $page = $this->load->view($activeTemplate[0]->short_name.'/pages/404', '', true); 
        }
        $footerLinks = $this->site->getFooterNav(); 
        $toprankings = $this->site->getTop5();
        //$top5 = Array ( Array ( "character_name" => "Kid Wonder" ), Array ( "character_name" => "Ryu Satoshi" ), Array ( "character_name" => "Oriel" ), Array ( "character_name" => "\"The Ladies Man\" Luscious Landon" ), Array ( "character_name" => "\"The Outlaw\" Mike Mayhem" ));
        $data['$toprankings']=$toprankings;
        $this->template
        ->title($siteInfo[0]->site_name,$siteInfo[0]->site_slogan)
        ->prepend_metadata('<link rel="stylesheet" type="text/css" href="http://www.kansasoutlawwrestling.com/assets/css/'.$activeTemplate[0]->short_name.'.css" />')
        ->set('footerLinks', $footerLinks)
        ->set('page', $page)
        ->set('toprankings', $toprankings)               
        ->set_partial('header', $activeTemplate[0]->short_name.'/header')
        ->set_partial('navigation', $activeTemplate[0]->short_name.'/navigation')            
        ->set_partial('content', $activeTemplate[0]->short_name.'/content', $data)
        ->set_partial('footer', $activeTemplate[0]->short_name.'/footer')
        ->build('kow');

View:

<?php

for($i=0;$i < count($toprankings); $i++) 
{
   echo "character_name: ".$toprankings[$i]['character_name']."<br>";

}

?>   
  • 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-26T08:44:07+00:00Added an answer on May 26, 2026 at 8:44 am

    Your for loop is backwards.

    for ($i = 0; $i >= count($top5); $i++){
    

    should be

    for($i=0;$i<count($top5);$i++)
    

    $i starts at 0 and therefore will never be more than count and even if it is equal will never increment nor iterate.


    Try deleting everything in your view except the top5 part, and change that to:

    <?php 
        for($i=0;$i<count($top5);$i++)
        {
            foreach($top5[$i] as $k=>$v)
            {
            echo $k."   =    ".$v."<BR>";
            }
        }
    ?>
    

    just to see if it’s working. Also, it’d help to know what templating system you are using.

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

Sidebar

Related Questions

What I need to have happen: PHP needs to launch an server app which
So I need to track changes that happen on a Mysql table. I was
need ask you about some help. I have web app running in Net 2.0.
Need some help about with Memcache. I have created a class and want to
Need to insert selected text on the page into textarea. There must be some
I happen to have tables with timestamp without time zone column in my database.
I need to do something completely insane. I have 2 views that have the
I have a web app which pulls in information via ajax after the page
I happen to have a database with a table that holds all possible combination
I have a collection of worker classes, and I need to be able to

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.