0

我正在尝试从数据库中检索一些值并将其放入带有 codeigniter 的表中,但它似乎不起作用?

这是我的模型

function getlogrecords(){

    $query = $this->db->get('selfimpact_log');
    return $query->results();
}

这是我的控制器

public function abt_article() {

         $data= array();
        $query = $this->abt_db->getlogrecords();
             $data['logs']= $query;

        $this->load->view('abt_article', $data);

    }

风景

<table data-role="table" id="table-column-toggle" data-mode="columntoggle" class="ui-responsive table-stroke" data-inset="true">
        <thead>
            <tr>
                <th data-priority="1">Statements</th>
                <th data-priority="2">Try these positive affirmations</th>
            </tr>
        </thead>
        <tbody>
            <?php if(isset($logs)): foreach($logs as $row);?>
            <tr>
                <td><?php echo $row->log_id;?></td>  
                <td>I am ashamed and embarrassed that I have Postnatal Depression.</td> 
            </tr>
            <tr>
                <td><?php echo $row->logTime;?></td>
                <td>What I am feelings are symptoms of illness. I am not making this up</td>
            </tr>
            <?php endforeach;?>

            <?php else : ?>
            <tr>
                <td>No records found.</td>

            </tr>

            <?php endif;?>
        </tbody>
    </table>
4

1 回答 1

1

$query->results()不是 CodeIgniter 中的函数。应该是$query->result(),不's'

此外,在您的视图文件中:

<?php if(isset($logs)): foreach($logs as $row);?>

分号 ( ;) 应该是冒号 ( :):

<?php if(isset($logs)): foreach($logs as $row):?>
于 2013-08-28T15:37:27.187 回答