我正在开发一个我想要创建用户个人资料的网站。我有一个页面,我列出了表中的所有用户。我做了一个按钮来链接到用户的个人资料页面。配置文件页面从数据库中获取正确的数据,但页面会一直反复加载所有视图。
这是填写用户表的代码:
<table class="table table-hover">
<thead>
<tr>
<th>Naam</th>
<th>Voornaam</th>
<th>Gebruikersnaam</th>
<th>Geboortedatum</th>
<th>Studienummer</th>
<th>Aanmaakdatum</th>
</tr>
</thead>
<tbody>
<?php foreach ($records as $record){ ?>
<tr>
<td><?= $record->usr_naam; ?></td>
<td><?= $record->usr_voorNaam; ?></td>
<td><?= $record->usr_userNaam; ?></td>
<td><?= $record->usr_geboorteDatum; ?></td>
<td><?= $record->usr_studyNr; ?></td>
<td><?= $record->usr_timeStamp; ?></td>
<td>
<a class="btn btn-default btn-circle btn-outline" href="<?php echo site_url('patient/id/'.$record->usr_id);?>"><i class="fa fa-arrow-right"></i></a>
<button class="btn btn-default btn-circle btn-outline" type="button"><i class="fa fa-pencil"></i></button>
<button class="btn btn-default btn-circle btn-outline" type="button"><i class="fa fa-bar-chart"></i></button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
每一行都会生成一个按钮,其中包含指向用户个人资料页面的链接。
例如:http://localhost/nemo-v2/patient/id/1
此链接指的是患者控制器中的id功能。 这是id函数的代码
public function id(){
$userid = $this->uri->segment(3);
$this->load->model('User_model');
$data['record'] = $this->User_model->getUser($userid);
$this->load->view('templates/head');
$this->load->view('templates/menu');
$this->load->view('pages/patient', $data);
$this->load->view('templates/footer');
}
从数据库中选择用户数据后,将调用视图以显示配置文件页面。这里的问题是程序继续循环id函数并保持视图堆叠在彼此之下。
这是患者视图的代码。现在我只使用var_dump()来显示数据库的结果。所有其余的只是带有一些虚拟数据的HTML。事实上,这需要用数据库中的数据替换。
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-md-4">
<div class="col-md-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Profile detail</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="edit-link">
<i class="fa fa-pencil"></i>
</a>
</div>
</div>
<div class="ibox-content">
<h4><strong>Jef</strong></h4>
<p><i class="col-lg-1 fa fa-map-marker"></i> Genk 3600</p>
<p><i class="col-lg-1 fa fa-birthday-cake"></i> 06/02/1985</p>
<p><i class="col-lg-1 fa fa-envelope"></i> jef.jef@uhasselt.be</p>
<p><i class="col-lg-1 fa fa-phone"></i> 0473 23876546</p>
<h5>
About me
</h5>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitat.
</p>
<div class="user-button">
<div class="row">
<div class="col-md-6">
<a class="btn btn-default btn-sm btn-block" href="<?php echo site_url('statistics');?>"><i class="fa fa-bar-chart"></i> Statistics</a>
</div>
<div class="col-md-6">
<a class="btn btn-default btn-sm btn-block" href="<?php echo site_url('alerts');?>"><i class="fa fa-bell"></i> Alerts</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Devices</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="edit-link">
<i class="fa fa-plus"></i>
</a>
</div>
</div>
<div class="ibox-content">
<h5><i class="col-lg-1 fa fa-heartbeat"></i> Pulse</h5>
<h5><i class="col-lg-1 fa fa-heart"></i> Smart scale</h5>
<h5><i class="col-lg-1 fa fa-arrows-v"></i> <h5>Blood pressure monitor</h5>
</div>
</div>
</div>
<div class="col-md-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Alerts</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="edit-link">
<i class="fa fa-pencil"></i>
</a>
</div>
</div>
<div class="ibox-content">
<h5><i class="col-lg-1 fa fa-medkit"></i> High risk: 1</h5>
<h5><i class="col-lg-1 fa fa-warning"></i> Medium risk: 4</h5>
<h5><i class="col-lg-1 fa fa-check"></i> Normal: 12</h5>
<h5><i class="col-lg-1 fa fa-eye-slash"></i> Missed: 0</h5>
</div>
</div>
</div>
</div>
<div class="col-md-8">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Extra information</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="ibox-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu dui sed nulla iaculis rutrum a id tortor. Vestibulum feugiat bibendum ipsum, in egestas velit volutpat in. Mauris lacus quam, accumsan eu nulla ac, tincidunt tristique urna. Etiam molestie facilisis elit, ut molestie orci commodo semper. Suspendisse id leo nec ipsum lobortis maximus pretium in ipsum. Praesent vehicula, est eleifend tristique vestibulum, mauris ipsum molestie massa, eget lobortis quam lectus vitae odio. Suspendisse quis lacus at justo malesuada tincidunt. Quisque ut facilisis erat, eget aliquam ipsum. Maecenas fermentum augue mauris, sed commodo purus sodales nec. Nullam bibendum quam in elit faucibus, et tincidunt ex ultricies. Nam eu elementum ex, ac vehicula arcu.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu dui sed nulla iaculis rutrum a id tortor. Vestibulum feugiat bibendum ipsum, in egestas velit volutpat in. Mauris lacus quam, accumsan eu nulla ac, tincidunt tristique urna. Etiam molestie facilisis elit, ut molestie orci commodo semper. Suspendisse id leo nec ipsum lobortis maximus pretium in ipsum. Praesent vehicula, est eleifend tristique vestibulum, mauris ipsum molestie massa, eget lobortis quam lectus vitae odio. Suspendisse quis lacus at justo malesuada tincidunt. Quisque ut facilisis erat, eget aliquam ipsum. Maecenas fermentum augue mauris, sed commodo purus sodales nec. Nullam bibendum quam in elit faucibus, et tincidunt ex ultricies. Nam eu elementum ex, ac vehicula arcu.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu dui sed nulla iaculis rutrum a id tortor. Vestibulum feugiat bibendum ipsum, in egestas velit volutpat in. Mauris lacus quam, accumsan eu nulla ac, tincidunt tristique urna. Etiam molestie facilisis elit, ut molestie orci commodo semper. Suspendisse id leo nec ipsum lobortis maximus pretium in ipsum. Praesent vehicula, est eleifend tristique vestibulum, mauris ipsum molestie massa, eget lobortis quam lectus vitae odio. Suspendisse quis lacus at justo malesuada tincidunt. Quisque ut facilisis erat, eget aliquam ipsum. Maecenas fermentum augue mauris, sed commodo purus sodales nec. Nullam bibendum quam in elit faucibus, et tincidunt ex ultricies. Nam eu elementum ex, ac vehicula arcu.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu dui sed nulla iaculis rutrum a id tortor. Vestibulum feugiat bibendum ipsum, in egestas velit volutpat in. Mauris lacus quam, accumsan eu nulla ac, tincidunt tristique urna. Etiam molestie facilisis elit, ut molestie orci commodo semper. Suspendisse id leo nec ipsum lobortis maximus pretium in ipsum. Praesent vehicula, est eleifend tristique vestibulum, mauris ipsum molestie massa, eget lobortis quam lectus vitae odio. Suspendisse quis lacus at justo malesuada tincidunt. Quisque ut facilisis erat, eget aliquam ipsum. Maecenas fermentum augue mauris, sed commodo purus sodales nec. Nullam bibendum quam in elit faucibus, et tincidunt ex ultricies. Nam eu elementum ex, ac vehicula arcu.</p>
</div>
</div>
</div>
<?php var_dump($record); ?>
</div>
</div>
模型中没有错误,因为从数据库中选择了正确的数据。我已经搜索了几天,但我无法弄清楚问题是什么。 我正在使用CodeIgniter 3.0(候选版本3)。我已经在CodeIgniter 2.2.1中测试了我的代码,但结果相同。
提前致谢。
答案 0 :(得分:0)
问题是由页脚中的脚本引起的。
<script src="/inspinia_admin-v1.9.2/js/inspinia.js"></script>
该剧本来自Inspinia(bootstrap主题)。我会让来自Inspinia的人知道这个剧本出了问题。
我并不是说Inspinia不是一个好主题相反Inspinia是一个很棒的主题,有很多功能。
更新:我在脚本中做了一些调试,得出的结论是这个函数导致了这个问题。
// Append config box / Only for demo purpose
$.get("skin-config.html", function (data) {
$('body').append(data);
});
显然这是一个仅用于演示目的的功能,所以我只是评论它并且一切正常。