2016-09-19 4 views
0

フッタデータを追加し、そのフッタデータをフロントエンドに表示するバックエンド機能を作成しました。しかし、データを取得して表示している間は、index.phpページでのみ動作していますが、残りのページでは動作していません。残りのページにPHPエラーが表示されます。メッセージ:codeigniterフレームワークを使用してフロントエンドにフッタウィジェットデータを表示

未定義のプロパティ:stdClass :: $ get_in_touch

データベースを作成し、ヘッダーイメージとフッターデータを1つのテーブルに保存しました。したがって、取得中は他のページでは機能しません。

ようこそ(これは私のインデックスページコントローラです):ここに私のコードです(。私はフッタデータ取得PHPのエラーを表示することはできませんよ)

public function index() 
{ 
    $this->load->model('index_model'); 
    $data['records2'] = $this->index_model->get_all_client_images(); 
    $data['mainpage'] = "index"; 
    $this->load->view('templates/template',$data); 
} 

体験談コントローラー:

public function index() 
{ 

    $this->load->model('testimonial_model'); 
    $data['records2'] = $this->testimonial_model->get_all_testimonials(); 
    $data['mainpage'] = "testimonial"; 
    $this->load->view('templates/template',$data); 
} 

モデル(Index_model):

function get_all_client_images() 
{ 

    $this->db->select('B.*'); 
    $this->db->from('banner AS B'); 
    $q = $this->db->get(); 
    if($q->num_rows()>0) 
    { 
     return $q->result(); 
    } 
    else 
    { 
     return false; 
    } 
} 

testimonial_model:

function get_all_testimonials() 
{ 

    $this->db->select('T.*'); 
    $this->db->from('testimonials AS T'); 
    $this->db->where(array('T.status'=>1)); 
    $q = $this->db->get(); 
    if($q->num_rows()>0) 
    { 
     return $q->result(); 
    } 
    else 
    { 
     return false; 
    } 
} 

footer.php

<?php if(isset($records2) && is_array($records2)):?> 
      <?php foreach ($records2 as $r):?> 
<div class="col-md-12"> 
        <div class="col-sm-3 "> 
         <div class="footerWidget "> 
          <h3 class="getintouch">Get In Touch</h3> 
          <address> 
           <p> 
            <?php echo $r->get_in_touch;?> 
            Phone: +91-080-420-131-80 <br> 
            Cell:+91-924-128-9345<br> 
            <a href="mailto:[email protected]" class="notification">Email: [email protected]</a> 
           </p> 
          </address> 
         </div> 
        </div> 
        <div class="col-sm-3 abouts"> 
          <div class="footerWidget "> 
           <h3 class="ourcompany">Our Company</h3> 
           <?php echo $r->our_company;?> 
          </div> 
        </div> 
        <div class="col-sm-3 specializationss"> 
          <div class="footerWidget "> 
           <h3 class="ourspecialization">Our Specialization</h3> 
           <?php echo $r->our_specialization;?> 
          </div> 
        </div> 

+0

あなたは '$ r' – gdros

+0

@gdrosは$ rの – user6728960

+0

まあ、あなたの証言記録が'持っていないと思われているどのようなコードを更新しているものは表示されません。 get_in_touch'フィールド。 – gdros

答えて

0

を試してみてください

代わりの

$this->db->select('T.*'); 
$this->db->from('testimonials AS T'); 
$this->db->where(array('T.status'=>1)); 
$q = $this->db->get(); 
+0

私は推薦を得ているが、フロントエンドから追加しているフッターデータを表示できない – user6728960

+0

フッターにはエラーが表示されない – user6728960

+0

ああ!! OK。 footer.phpファイルで 'print_r($ records2)'を試して、すべての内容が取得されたかどうか確認しましたか? –

関連する問題