ロードされません:(api.php)ビュー私はこのようにコントローラを持ってここビュー についてお聞きしたい
public function export_excel() {
$date = new DateTime($this->input->post('date_fil'));
$curr_date = $date->format('Y-m-d ');
$user = $this->input->post('sales_name');
$checked = $this->input->post('cb_month');
$month = date('m');
if ((int) $checked == 1) {
$this->form_validation->set_rules('sales_name', 'Sales Name', 'required');
if ($this->form_validation->run() == false) {
$this->output->set_output(json_encode([
'result' => 0,
'error' => $this->form_validation->error_array()
]));
return false;
}
$this->db->select('t1.act_id, t2.login, t1.cust_name, t1.act_type, t1.act_detail, t1.date_added, t1.date_modified, t1.act_notes')
->from('activity as t1')
->join('user as t2', 't1.user_id = t2.user_id', 'LEFT')
->where('t2.login', $user)
->where('MONTH(t1.date_added)', $month);
$query = $this->db->get();
$result = $query->result_array();
$data = array('title' => 'Sales Report',
'user' => $result);
$this->load->view('report/vw_excel', $data);
// Selecting data by Date ----------------------------------------------
} else {
$this->form_validation->set_rules('sales_name', 'Sales Name', 'required');
$this->form_validation->set_rules('date_fil', 'Date', 'required');
if ($this->form_validation->run() == false) {
$this->output->set_output(json_encode([
'result' => 0,
'error' => $this->form_validation->error_array()
]));
return false;
}
$this->db->select('t1.act_id, t2.login, t1.cust_name, t1.act_type, t1.act_detail, t1.date_added, t1.date_modified, t1.act_notes')
->from('activity as t1')
->join('user as t2', 't1.user_id = t2.user_id', 'LEFT')
->where('t2.login', $user)
->where('DATE(t1.date_added)', $curr_date);
$query = $this->db->get();
$result = $query->result_array();
$data = array('title' => 'Sales Report',
'user' => $result);
$this->load->view('report/vw_excel', $data);
}
、ここでは、私はそれがフォルダの下にありますロードするビューですが(レポート/ vw_excel)私は、他のビューのフォルダ(管理者/ admin_view) をonSubmit = 'API/export_excel'からそれを呼び出す
<body>
<main>
<h1>Excel Report</h1>
<p><a href="<?php echo base_url('report/export_excel') ?>">Export to Excel</a></p>
<table border="1" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Sales Name</th>
<th>Customer Name</th>
<th>Activity</th>
<th>Detail</th>
<th>Start Time</th>
<th>Finish Time</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<?php $i=1; foreach($user as $xuser) { ?>
<tr>
<td><?php echo $xuser['act_id']; ?></td>
<td><?php echo $xuser['login']; ?></td>
<td><?php echo $xuser['cust_name']; ?></td>
<td><?php echo $xuser['act_type']; ?></td>
<td><?php echo $xuser['act_detail']; ?></td>
<td><?php echo $xuser['date_added']; ?></td>
<td><?php echo $xuser['date_modified']; ?></td>
<td><?php echo $xuser['act_notes']; ?></td>
</tr>
<?php $i++; } ?>
</tbody>
</table>
</main>
この
"$this->load->view('report/vw_excel', $data);"
ビューをロードしないでください。
結果はブラウザのネットワークに表示されますが、ビューは読み込まれません。 network view
ありがとう。
$ checked == 1であるかどうかに関係なく、同じことが起こりますか? – TimBrownlaw
あなたのスクリーンショットから見たことの一つは、あなたのリンクに$ config ['base_url']を設定していないからです。 – TimBrownlaw
あなた自身に尋ねるべきことは何ですか...あなたのビューを読み込むステートメントにスクリプトの実行が到達していますか?だから、私はあなたの$ _POSTの値をチェックしています - var_dump()を使用しています。あなたのSQLをチェックして、彼らが結果を得ていることを確認し、それらを正しくテストしています。コード実行がどこに向かうのか見てみましょう...標準的なデバッグ手順... – TimBrownlaw