如何在下一页的引导数据表中查看顶部的用户名。我的问题是 当用户客观地给出答案问题时,其问题和答案列表将转到下一页的下一页,我希望连续看到该用户名。 我的问题是,下一页的用户名甚至会在上一页显示该用户结束的问题和答案。 当该用户名的下一页上用户的所有问题和答案均不应显示在该用户名的下一页上时,如何解决该问题。
<div id="user-answer-datatable-responsive3">
<table id="user-answer-datatable-responsive1" class="table table-striped table-bordered dt-responsive nowrap bulk_action" cellspacing="0" width="100%">
<thead>
<tr>
<th style="width: 40%;">Athlete Name/Questions</th>
<th>Users Answer</th>
</tr>
<!-- <tr>
<th style="width: 40%;">Athlete Name/Questions</th>
<th>Users Answer</th>
</tr>-->
</thead>
<tbody id="render-list-of-order1">
<?php $rows = 1; $i=1;?>
<?php foreach ($data['question'] as $key => $value) { ?>
<?php if($rows % 10 != 0){ ?>
<tr style="background-color:#f9f9f9">
<td colspan="2" ><b><?php echo $value['first_name'] . ' ' . $value['last_name']; ?></b></td>
<td class="hidden"></td>
</tr>
<?php }?>
<?php print_r($rows++); ?>
<?php foreach ($value['options_useranswer'] as $key => $values) { ?>
<tr style="background-color:white">
<td style=""><?php echo $values['questions']; ?></td>
<td style=""><?php echo $values['options_names']; ?></td>
</tr>
<?php if($rows % 10 == 0 ){
print_r(($rows).'df');?>
<tr style="background-color:#f9f9f9">
<td colspan="2" ><b><?php echo $value['first_name'] . ' ' . $value['last_name']; ?></b></td>
<td class="hidden"></td>
</tr>
<?php $rows++; } ?>
<?php print_r('('.($rows++).')');?>
<?php } ?>
<?php } ?>
</tbody>
</table>
</div>
Php代码:
public function answers() {
$response = $this->Godspeed->answersData($date = '1');
$data['data']['question'] = $response;
$this->load->template(array("Portal/User_answer" => ""), $data);
}
foreach ($data as $key => $value) {
$this->db->select('options.op_id,options.options_names,user_answers.q_id,question.questions,user_answers.date');
$this->db->from('user_answers');
$this->db->join('question', 'question.id = user_answers.q_id');
$this->db->join('options', 'options.op_id = user_answers.ans_respons','left');
$user_id = $value['user_id'];
$this->db->where("user_id = $user_id");
$this->db->where('user_answers.date BETWEEN "' . $date_current . $times[0] . '" and "' . $date_current . $times[1] . '"');
$query = $this->db->get();
foreach ($query->result_array() as $resultDatas) { //while loop can be possible
$data[$key]['options_useranswer'][] = $resultDatas;
}
}
return $data;
显示的数据库图像:
首页图片显示: