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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:30:51+00:00 2026-06-11T09:30:51+00:00

I have the following simple code: The model: function get_last_ten_entries() { $this->db->get(‘property’); } controller:

  • 0

I have the following simple code:
The model:

function get_last_ten_entries()         
{
    $this->db->get('property');
}

controller:

public function load_recent()
{
    $data['info'] = $this->propertymodel->get_last_ten_entries();
    $this->load->view('load_property', $data);
}

view:

<?
echo $data['id'];
?>

This is not working. Am sure i am doing something wrong because the error shown says

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: data

Filename: views/load_property.php

Line Number: 2

Property is a table in the database in which there is a field called id. what’s going wrong?

Thank you all

  • 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-11T09:30:52+00:00Added an answer on June 11, 2026 at 9:30 am

    To fix the error, you’ll need to use $info in your view, rather than $data as your array indexes in your controller correspond to variables in your view.

    $this->db->get('property') returns all rows in the table property, but your function name suggests that you are trying to get the last 10 entries. I suggest you read CodeIgniter’s Active Record documentation for more information. You also need to return your query.

    You need to generate results from you query. CodeIgniter’s Query Results documentation provides useful information on how to use the results of your query. What you’re trying to achieve is a bit vague but you code could look something like this:

    Model

    function get_last_ten_entries()         
    {
        return $this->db->get('property');  //Perform query (you'll need to update to select what you actually want from you database)
    }
    

    Controller

    public function load_recent()
    {
        $data['last_entries'] = $this->propertymodel->get_last_ten_entries();
        $this->load->view('load_property', $data);
    }
    

    View

    foreach ($last_entries->result_array() as $entry)
    {
       echo $entry['id'];
    }
    

    Or, if you rather use an object, instead of an array:

    foreach ($last_entries->result() as $entry)
    {
       echo $entry->id;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following simple code: def get(): return [lambda: i for i in
i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have the following simple code abstract class A { public abstract void Test(Int32
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have got the following very simple code: function init() { var articleTabs =
Let's say I have the following, very simple block of code: <script> function hasVal(field)
I have written a function having the following signature: def action_handler(request, model): This action_handler
I have the following very simple code snippet which is loaded from a separate
I have the simple following code, which is working in a ruby (not rails)
I have the following code which creates a simple window with two buttons which

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.