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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:35:46+00:00 2026-05-14T03:35:46+00:00

I have a model, view and controller not interacting correctly, and I do not

  • 0

I have a model, view and controller not interacting correctly, and I do not know where the error lies.

First, the controller. According to the Code Igniter documentation, I’m passing variables correctly here.

function view() {
        $html_head = array( 'title' => 'Estimate Management' );

        $estimates = $this->Estimatemodel->get_estimates();

        $this->load->view('html_head', $html_head);
        $this->load->view('estimates/view', $estimates);
        $this->load->view('html_foot');
    }

The model (short and sweet):

function get_estimates() {
        $query = $this->db->get('estimates')->result();
        return $query;
    }

And finally the view, just to print the data for initial development purposes:

<? print_r($estimates); ?>

Now it’s undefined when I navigate to this page. However, I know that $query is defined, because it works when I run the model code directly in the view.

  • 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-14T03:35:46+00:00Added an answer on May 14, 2026 at 3:35 am
    $estimates = $this->Estimatemodel->get_estimates();
    $this->load->view('estimates/view', $estimates);
    

    You’re loading the return of $this->Estimatemodel->get_estimates() as the array of view variables. In other words, all the children of $estimates (assuming it can be treated as an array) are available in your view. But not the parent element.

    The key here is when loading a view the second parameter needs to be an array of values, not just a single value.

    $this->load->view('estimates/view', array('estimates' => $estimates));
    

    That should get the result you’re looking for, in fact, you’re already doing that for the html header view. Even though that view only has one variable, it’s passed as the single element of an array:

    $html_head = array( 'title' => 'Estimate Management' );
    $this->load->view('html_head', $html_head);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know Model-View-Controller well, have known about it for years and used it in
I have a Java project that I'm trying to implement with a model-view-controller design.
I have created model, controller and view with rails scaffold generator: rails g scaffold
I have the following model, view and controller. Model public class Person { public
I am trying to present a modal view controller. I have read the documentation,
I need to explain to a not-very-technical manager the MVC (model-view-controller) concept and ran
I'm writing my first application with Zendframework. My question is about the Model–View–Controller (MVC)
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Both OOD (Object-Oriented-Design) and MVC (Model-View-Controller) architectures have become staples of modern software design.
I am developing a website using the Model-View-Controller structure. In my html, I have

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.