我想在视图中的单个表中显示返回两个数组值,我已经在表中运行了第一个数组值。
控制器
df_result['unique_products'] = df_result.apply(lambda row: unique_products(df_products, 3, row['ID'], row['Key_Date']), axis=1)
df_result.head()
ID Key_Date unique_products
0 0 2015-05-31 NaN
1 2 2015-06-30 1.0
2 1 2015-07-31 1.0
3 0 2015-08-31 1.0
4 1 2015-09-30 2.0
模型
public function communication(){
$session_data = $this->session->userdata('admin_logged_in');
$id = $session_data['id'];
if ($this->session->userdata('admin_logged_in')) {
$data['get_all_mail'] = $this->admin_model->get_all_mails($id);
$data['get_out_mail'] = $this->admin_model->get_out_mails($id);
$this->load->view('communication',$data);
}
}
视图
function get_all_mails($id){
$query = $this->db->query("SELECT * FROM t_communication_posting WHERE FIND_IN_SET($id, REPLACE(`to`, ', ', ',')) OR FIND_IN_SET($id, REPLACE(`cc`, ', ', ',')) OR FIND_IN_SET($id, REPLACE(`bcc`, ', ', ',')) <> 0");
return $query->result_array();
}
这里我想在视图页面的上表中运行第二个数组值($ data [&#39; get_out_mail&#39;]),我如何在单个表中运行两个数组值。
答案 0 :(得分:1)
您可以在视图文件中添加另一个循环。
<?php foreach ($get_all_mail as $get_all_mails) {
?>
<tr onclick="return get_mail_content(<?php echo $get_all_mails['m_id']; ?>)" id="target-list">
<td class="email-title" >
<?php echo $get_all_mails['from']; ?>
</td>
<td class="email-body" >
<?php echo $get_all_mails['subject'] ?>
</td>
</tr>
<?php } ?>
<?php foreach ($get_out_mail as $get_out_mails) {
?>
<tr onclick="return get_mail_content(<?php echo $get_out_mails['m_id']; ?>)" id="target-list">
<td class="email-title" >
<?php echo $get_out_mails['from']; ?>
</td>
<td class="email-body" >
<?php echo $get_out_mails['subject'] ?>
</td>
</tr>
<?php } ?>
这会对你有帮助。
答案 1 :(得分:0)
您可以在second foreach
完成后运行first foreach
,如下所示
<table id="myTable">
<tbody>
<?php foreach ($get_all_mail as $get_all_mails) { ?>
//...... tr here
<?php } ?>
<?php foreach ($get_out_mail as $get_out_mails) { ?>
//...... tr here
<?php } ?>
</tbody>
</table>