用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1639|回复: 7
收起左侧

[分页] 求助。每次视图循环体结束。还会输出一次没有数据的循...

[复制链接]
发表于 2017-4-1 05:22:14 | 显示全部楼层 |阅读模式
//管理用户控制器
PHP复制代码
public function index(){
               
                //后台设置后缀为空,否则分页出错
                $this->config->set_item('url_suffix', '');
                //载入分页类
                $this->load->library('pagination');
                $perPage = 16;
 
                //配置项设置
                $config['base_url'] = site_url('admin/user/index');
                $config['total_rows'] = $this->db->count_all('user');
                $config['per_page'] = $perPage;
                $config['uri_segment'] = 4;
                $config['first_link'] = '第一页';
                $config['prev_link'] = '上一页';
                $config['next_link'] = '下一页';
                $config['last_link'] = '最后一页';
 
                $this->pagination->initialize($config);
 
                $data['links'] = $this->pagination->create_links();
                // p($data);die;
                $offset = $this->uri->segment(4);
                $this->db->limit($perPage, $offset);
       
                $data['user'] = $this->user->get_user();
                //p($data['user'] );die();
                $this->load->view('admin/user-list.html',$data);
        }
 
复制代码

视图代码:
HTML复制代码
<?php foreach($user as $v): ?>
                       
                                        <tr class="text-c">
                                       
                                                <td><input type="checkbox" value="1" name=""></td>
                                                <td>
                                                        <?php echo $v['uid'] ?>
                                                </td>
 
                                                <td><u style="cursor:pointer" class="text-primary"><?php echo $v['username'] ?></u></td>
                                                <td>
                                                        <?php echo $v['qq'] ?>
                                                </td>
                                                <td>
                                                        <?php echo date('H:i:s',$v['regdate']) ?>
                                                </td>
                                                <td>
                                                        <?php echo $v['ye'] ?>
                                                </td>
                                                <td class="user-status"><span class="label label-success"><?php echo $v['qx'] ?></span></td>
                                                <td class="f-14 user-manage">
                                                        <a style="text-decoration:none" href="javascript:;" title="停用"><i class="icon-hand-down"></i></a>
                                                        <a title="编辑" href="javascript:;" class="ml-5" style="text-decoration:none"><i class="icon-edit"></i></a>
                                                        <a style="text-decoration:none" class="ml-5" href="javascript:;" title="修改密码"><i class="icon-key"></i></a>
                                                        <a title="删除" href="<?php echo site_url('admin/user/del/'.$v['uid']) ?>" style="text-decoration:none"><i class="icon-trash"></i></a>
                                                </td>
                                        </tr>
                       
                       
                <?php endforeach; ?>
 
 
复制代码








 楼主| 发表于 2017-4-1 05:24:05 | 显示全部楼层
发表于 2017-4-1 09:31:46 | 显示全部楼层
最后一条数据不是有个8:00:00吗?
 楼主| 发表于 2017-4-1 13:54:10 | 显示全部楼层
Michael锐生 发表于 2017-4-1 09:31
最后一条数据不是有个8:00:00吗?

每一页最后一天都是多的不晓得哪里来的数据。我只调用16条,还会多显示一条。条。
发表于 2017-4-1 16:39:15 | 显示全部楼层

CI 不会无中生有,应该是你哪里的数据出问题了,比如 get_user(),建议一步一步跟踪下程序的运行。
 楼主| 发表于 2017-4-1 18:33:23 | 显示全部楼层
Hex 发表于 2017-4-1 16:39
CI 不会无中生有,应该是你哪里的数据出问题了,比如 get_user(),建议一步一步跟踪下程序的运行。 ...

我猜测,视图循环体运行结束后,又运行了一边没有数据的循环体。日期才回是空值时格式化的日期。就是不知道怎么会这样。
发表于 2017-4-5 10:57:40 | 显示全部楼层
夏桐 发表于 2017-4-1 13:54
每一页最后一天都是多的不晓得哪里来的数据。我只调用16条,还会多显示一条。条。 ...

你在加载视图之前,把user数据打印出来是没有的?

本版积分规则