Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Message: Undefined variable: infos why cant I connect the abouts table?
#1

[eluser]ytsejam[/eluser]
Hello ,
I am a novice coder and trying to learn about CI. Now mysite works in the homepage. Site opens , navigation and content splits into both sites. I can use ajax. I use MY_Controller.php :

Code:
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 home controller :
Code:
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);
  }

works and I can get the services-table from the database. and I can use it in the view file as :
Code:
<ul class="blog-medium">
&lt;?php foreach($records as $row): ?&gt;
<li>    
<div class="blog-medium-text">
<h1><a href="./post.html">&lt;?php echo $row->title; ?&gt;</a></h1>
<p class="blog-medium-excerpt">&lt;?php  echo $row->content; ?&gt;<br />
<a href="./post.html" class="read_more">Devamını Okumak için &rarr;</a></p>
</div>
&lt;?php endforeach ?&gt;

But when i click about page I cant get the about table . It gives me undefined variable infos.
about controller :
Code:
public function view($page = 'about')
  {
  $this->load->model('about_model');
   $this->load->helper('text');
   $data['infos']= $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 my about view :

Code:
&lt;?php foreach($infos as $row): ?&gt;
      <h3>
      &lt;?php echo $row->title; ?&gt;</h3>
      &lt;!-- ELEGANT HORIZONTAL LINE --&gt;
      <div class="hr"> </div>
      &lt;!-- NUMBERED LIST --&gt;

&lt;?php echo $row->content; ?&gt;
&lt;?php endforeach; ?&gt;
thank you .


Messages In This Thread
Codeigniter Message: Undefined variable: infos why cant I connect the abouts table? - by El Forum - 08-05-2012, 12:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB