尝试获取数据codeigniter的问题 [英] Issue trying to fetch data codeigniter

查看:57
本文介绍了尝试获取数据codeigniter的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图文件中遇到了这个错误(还有更多有关索引ID,用户名,名称,姓氏,密码,类型,状态,日期的错误):

I got this errors in the view file (and so many more about the indexes id,username, name, lastname, password, type, status, date):

https://i.gyazo.com/d8bda30b1fafce47ed2125d590c5b4e4.png

我只显示存储在表 usuarios中的包含简单用户( type = 1)的行

I gotta show ONLY the rows that contain "simple" users ("type = 1") which are stored inside the table "usuarios"

表 usuarios。

Table "usuarios".


usuarios包括:(id,用户名,名称,姓氏,密码,类型,状态,日期)。

"usuarios" includes:(id,username,name,lastname,password,type,status,date).

当我以管理员身份进入系统时,程序必须显示一个表,其中所有简单用户都存储在表中 usuarios。

When i enter the system as an ADMIN the program must show a table with all the "simple" users stored in the table "usuarios".

我需要这样的东西:

https://i.gyazo.com/36f11b368a339964f1b734cea0177734.png

这是我的代码:

我的视图文件(用户视图):

My view file ("user_view"):

                <table class="table table-hover" align="center" border="1" cellspacing="0" cellpadding="0" width="700" id="tabla_busqueda">
                <thead>
                    <th>id</th>
                    <th>User</th>
                    <th>Name</th>
                    <th>Lastname</th>
                    <th>Password</th>
                    <th>Type</th>
                    <th>Status</th>
                    <th>Date</th>
                </thead>


<tbody>

<?php

if (count($records) > 0 && $records != false)
 { 

    foreach($records as $record) {
    echo "<tr> 
<td>".$records['id']."</td> 
<td>".$records['username']."</td> 
<td>".$records['name']."</td> 
<td>".$records['lastname']."</td> 
<td>".$records['password']."</td> 
<td>".$records['type']."</td> 
<td>".$records['status']."</td> 
<td>".$records['date']."</td> 
</tr>"; 

}
}

?>

</tbody>

</body>
</html>

我的模型函数:

    public function getINFOUSER(){

    $query = $this->db->get_where('usuarios',array('type'=>1));
    if ($query->num_rows() > 0 ) {
        $result = $query->result_array();
    }

    return $result; 

}

不知道现在该怎么做:S

Do not know what to do now :S

推荐答案

它是记录,而不是foreach内的记录:

It is record, not records inside foreach:

foreach($records as $record) {
    echo "<tr> 
<td>".$record['id']."</td> 
<td>".$record['username']."</td> 
<td>".$record['name']."</td> 
<td>".$record['lastname']."</td> 
<td>".$record['password']."</td> 
<td>".$record['type']."</td> 
<td>".$record['status']."</td> 
<td>".$record['date']."</td> 
</tr>"; 

}

希望这会起作用。

这篇关于尝试获取数据codeigniter的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆