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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:37:06+00:00 2026-06-15T23:37:06+00:00

Passing the array to the view works fine after this line: foreach($rb_data as $row){<table>}?>

  • 0

Passing the array to the view works fine after this line: foreach($rb_data as $row){<table>}?> but in my <body> above the table I am unable to use <h1><?php echo $rb_data['brand'];?></h1>
The error I receive is Message: Undefined index: brand. Ive tried initializing the array using $data = array() in the controller and this has not worked. Is there some other way to initialize the array so it can be used before the foreach statement? Thank you for taking a look.
Controller:

    public function community_single($rb){
        $data['rb_data'] =  $this->rootbeer_model->community_single($rb);
        $this->load->view('rb_community_single_view',$data);

    }

Model:

    public function community_single($rb){

        $this->rb_db->select('*');
        $this->rb_db->from('rb_selection');
        $this->rb_db->where('brand',$rb);
        $query = $this->rb_db->get();
        return $query->result_array();
    }
  • 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-15T23:37:07+00:00Added an answer on June 15, 2026 at 11:37 pm

    your $this->rootbeer_model->community_single($rb);
    will return an array like this
    ie, rb_data=[[id=>1,value=>'a'],[id=>2,value=>'b'],[id=>3,value=>'c']]

    so first you need to fetch the row that you wand, using this functions,

    1. foreach($rb_data as $row){<table>}?>
    
    2. $row = $rb_data->first_row()
       $row = $rb_data->last_row()
       $row = $rb_data->next_row()
       $row = $rb_data->previous_row()
    
    3.$row = $rb_data->row(5);
    

    then you can access `$row[‘band’]’

    `$rb_data` doesn't contains an index like `band` . `$rb_data` contains only rows
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam facing problem in passing array to view. this is my controller code.. function
I am passing a list to a view. My array looks like this: [football,
I have an ArrayCollection of objects. I'm passing this array to a horizontallist as
Ok, In my Codeigniter project I am passing a multidimensional array to my view.
I am passing an array from view to the controller using json.stringify() method. That
This code works fine. I am able to get a page of populated JSON
I have a view spec that was passing but is broken now that pagination
Ref. to my last post and sellibitze's comment to that post on passing array
I'm passing an array to a function and I'm curious if there is a
I'm having some trouble passing an array from controller to a javascript in 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.