2017-07-26 30 views
0

私のcodeigniterはページを表示していません。Codeigniterがデータを表示せず、ページが表示されない

モデル

function get_all_district_circulars() 
{ 

    $this->db->select('*'); 
    $this->db->from('district_circulars'); 
    $this->db->where('status', 1); 
    $this->db->order_by('id', 'desc'); 

    $query = $this->db->get(); 
    return $query->result(); 
} 

コントローラインデックス機能

public function index() 
{ 
    $dt['dist_circulars'] = $this->content_model->get_all_district_circulars(); 
    $this->load->view('parts/top'); 
    $this->load->view('parts/header'); 
    $this->load->view('parts/nav'); 
    $this->load->view('district_circulars', $dt); 
    $this->load->view('parts/footer'); 
} 

ビュー

<?php 
    foreach($dist_circulars as $dt_circulars){ 
?> 
    <tr> 
     <td></td> 
    </tr> 
<?php 

    } 
?> 

Iデルの場合このforeach機能をETE、ページが正しく表示されますが、私はそれを置く場合は、ページがロードしてThis site can’t be reachedを示すとChromeのコンソールが

私は何をすべきGET http://localhost/anandadhara/district_circulars/ net::ERR_CONNECTION_RESETを示していませんか?

UPDATE

1マイ.htaccess私はwampserver使用しています

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteBase /anandadhara/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 
</IfModule> 

を次のように2.2

UPDATE 2

私のファイル名がdistrict_circulars.phpです。

CLASS

class District_circulars extends CI_Controller { 
public function __construct() 
{ 
    parent::__construct(); 

    $this->load->model('content_model'); 
} 

別の更新

私はここに単一の結果を表示する場合は正常に動作します。

<?php 
    foreach($dist_circulars as $dt_circulars){ 
?> 
    <tr> 
     <td><?php echo $dt_circulars->id; ?></td> 
    </tr> 
<?php 

    } 
?> 

しかし、私は...

<td><?php echo $dt_circulars->id; ?></td> 
<td><?php echo $dt_circulars->memo_no; ?></td> 

または私はここで2つだけ空白のHTMLタグをつけていても...

<td></td> 
<td></td> 

のようにこちらのページを超える1つのフィールドを示す場合ERR_CONNECTION_RESETが表示され、connection_resetページのブラウザの空白ページが表示され、データが表示されません。

私はここで何が起こっているのか理解できません。

+0

ローディングモードが不足しているようですl。 '$ this-> load-> model( 'content_model');' – jagad89

+0

いいえ、私のモデル '$ this-> load-> model( 'content_model');を' public function __construct(){} 'にロードしました – Raj

+0

'var_dump($ dt);を試してください。 $ dt ['dist_circulars'] = $ this-> content_model-> get_all_district_circulars(); 'の後ろに置かれます。それは空に戻るかもしれません。 – jagad89

答えて

0

モデル:

//コントローラから呼び出す場合は、それをパブリック関数を作成する必要があり

public function get_all_district_circulars() 
{ 
//simplify your model call, use get instead of from 
return $this->db->select('*')->where('status', 1)->order_by('id', 'desc')->get('district_circulars')->result(); 


} 

ビュー:

場所ANチェックしても、PHPの代替構文たときにビュー内を使用する場合 http://php.net/manual/en/control-structures.alternative-syntax.php

<?php if(isset($dist_circulars)): ?> 

    <?php foreach($dist_circulars as $dt_circulars): ?> 


    <tr> 
     <td></td> 
    </tr> 

    <?php endforeach; ?> 

<?php endif; ?> 
関連する問題