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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:45:22+00:00 2026-06-17T11:45:22+00:00

I can’t retrieve values from $info (as stated below) in CodeIgniter View. Here is

  • 0

I can’t retrieve values from $info (as stated below) in CodeIgniter View.

Here is the scenario:
I explained everything the code.

function info() {
{...} //I retrieve results from database after sending $uid to model.
    $dbresults = $this->my_model->get_info($uid); //Assume that this model returns some value.


    foreach($dbresults as $row) {
        $info = $row->address; //This is what I need to produce the results
        $results = $this->my_model->show_info($info);

    return $results; //This is my final result which can't be achieved without using $row->address. so first I have to call this in my controller.

    }

    // Now I want to pass it to a view

    $data['info'] = $results;
    $this->load->view('my_view', $data);

    //In my_view, $info contains many values inherited from $results which I need to call one by one by using foreach. But I can't use $info with foreach because it is an Invalid Parameter as it says in an error.
  • 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-17T11:45:23+00:00Added an answer on June 17, 2026 at 11:45 am

    using $result inside foreach is not reasonable. Because in each loop $result will take a new value. So, preferably use it as an array and then pass it to your view. Besides, you should not use return inside foreach.

    function info() {
    {...} //I retrieve results from database after sending $uid to model.
        $dbresults = $this->my_model->get_info($uid); //Assume that this model returns some value
    
    $result = array();
        foreach($dbresults as $row) {
            $info = $row->address; //This is what I need to produce the results
            $result[] = $this->my_model->show_info($info);
    
        }
    
        // Now I want to pass it to a view
    
        $data['info'] = $result;
        $this->load->view('my_view', $data);
    }
    

    to check what $result array has do var_export($result); or var_dump($result); after the end of foreach. and make sure that this is what you want to send to your view.

    Now, in your view you can do:

    <?php foreach ($info as $something):?>
    
    //process
    
    <?php endforeach;?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain to me why the output from the following code is
Does anyone know how can I replace this 2 symbol below from the string
Can someone tell me where I'm going wrong here? basically I've written some code
Can we change the default action of the edit selected row button? Here is
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can anyone know how to add Radio Buttons in a Datagrid View Column?? I
Can i define a text view and a list view inside a linear layout.
Can anyone show me how to loop through my table in my view? The
Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can a Visual Studio 2008 custom tool be passed additional parameters from the custom

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.