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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:38:15+00:00 2026-06-09T09:38:15+00:00

I am a newbie in CI. I used MY_Controller.php as main controller. I could

  • 0

I am a newbie in CI. I used MY_Controller.php as main controller. I could open the ajax as the div#page loader. Now , My problem is although I load /about page, I get the database entries for the services model. How can i get the about table for the about controller ?

..
    function render_page($view) {
        if( ! $this->input->is_ajax_request() )
        {
          $this->load->view('templates/header', $this->data);
        }
        $this->load->view($view, $this->data);

        if( ! $this->input->is_ajax_request() )
        {
         $this->load->view('templates/menu');
         $this->load->view('templates/footer', $this->data);
        }
      }..

My services_model:

class Services_model extends CI_Model {

    function getAll() {
        $q = $this->db->get('services');
        if($q->num_rows() > 0){
        foreach ($q->result() as $row)
        {
            $data[] = $row;

            }
        return $data;
    }
    }
}

My home controller :

public function view($page = 'home')
{
$this->load->helper('text');
$this->data['records']= $this->services_model->getAll();
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
    // Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->render_page('pages/'.$page,$data);
}

When I use them in the home view there is no problem I can see the services_table :

<ul class="blog-medium">
<?php foreach($records as $row): ?>
<li>    
<div class="blog-medium-text">
<h1><a href="./post.html"><?php echo $row->title; ?></a></h1>
<p class="blog-medium-excerpt"><?php  echo $row->content; ?><br />
<a href="./post.html" class="read_more">Devamını Okumak için &rarr;</a></p>
</div>
<?php endforeach ?>

I want to use the same way in about page.
About_model:

class About_model extends CI_Model {
    function getAll() {
        $q = $this->db->get('abouts');
        if($q->num_rows() > 0){
        foreach ($q->result() as $row)
        {
            $data[] = $row;

            }
        return $data;
    }
    }
}

About controller :

 public function view($page = 'about')
    {
    $this->load->helper('text');
    $this->data['records']= $this->about_model->getAll();
    if ( ! file_exists('application/views/pages/'.$page.'.php'))
    {
        // Whoops, we don't have a page for that!
    show_404();
    }
    $data['title'] = ucfirst($page); // Capitalize the first letter
    $this->render_page('pages/'.$page,$data);
    }

And this is my view file of about :

<div id="content">
<?php foreach($infos as $row): ?>
<h3 style="text-align: center;"> <?php echo $row->title; ?></h3>
<div class="hr">    </div>
<?php echo $row->content; ?>
<?php endforeach; ?>

I get the error telling me :

Severity: Notice
Message: Undefined variable: infos
Filename: pages/about.php
Line Number: 3

Why cant i get the abouts table?

  • 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-09T09:38:17+00:00Added an answer on June 9, 2026 at 9:38 am

    You are calling a variable $infos in your foreach, but it is never passed in as a variable to your view.

    Read the docs about Adding Dynamic Data to the View

    You will either need to set $data['infos'] to something or, and I’m guessing this what you intended, use $records in your foreach

    The above answers your specific, but after you provided the repo for your source, there are issues you are struggling with. I highly suggest you read through the entire documentation, staring with the Introduction: Getting Started, continuing to the Tutorials and then General Topics.

    The reason you are having problems here, you have your routes.php setup to that everything is routed into the Home controller executing the view method. This method, while it accepts the page you want to see is always returning a fetch of the services model. Your other controllers are not getting executed at all. Based on your controller setup, if you would just remove the custom route, http://theurl/about would route to the About Controller. The default method to be loaded is index so if you change view to index, then it would be displayed by default.

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

Sidebar

Related Questions

As a newbie question, granted that a switch statement could be used, can the
I'm a ClearCase newbie and up until now have been used to SVN. Therefore,
Newbie to Fossil (or any other version control system) here. Used a proprietary one
I'm a newbie to this linq stuff. I never used any linq before. So
Please excuse the newbie question but I was wondering if I used Linq in
I'm a newbie in jQuery... I've used one jQuery plugin (Actually SimpleModal Plugin) in
Im a newbie in XML and i have some questions Can XML be used
Sorry for the newbie question, I'm used to C# so my Java framework knowledge
Total newbie question now... Suffice to say, I have searched for a completely noddy
I have long used the mysql_query() to do my stuff but now I am

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.