简体   繁体   English

从数据库中选择值不起作用?

[英]Selecting values from the database not working?

I am trying to retrieve some values from the database and put the onto a table with codeigniter but it does not seem to be working? 我正在尝试从数据库中检索一些值,并将其放在带有codeigniter的表上,但它似乎无法正常工作?

This is my model 这是我的模特

function getlogrecords(){

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

This is my controller 这是我的控制器

public function abt_article() {

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

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

    }

The view 风景

<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>

$query->results() is not a function in CodeIgniter. $query->results()不是CodeIgniter中的函数。 It should be $query->result() , no 's' . 应该是$query->result() ,没有's'

Also, in your view file: 另外,在您的视图文件中:

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

The semicolon ( ; ), should be a colon ( : ): 分号( ; ),应该是一个冒号( : ):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM