木下 敏夫
kino****@tktoo*****
2008年 7月 11日 (金) 12:59:22 JST
木下です。
> edit_confirmで反映した内容を表示させて、一覧に移動したいということですが、
> これは自分は逆に考えます。
私も edit_confirm という名称だと 「編集内容の確認」となって
edit 画面で「登録」を押した後で入力を確認させ
「OK」が押されたら登録する。
という流れだと思います。
> // 編集確認画面を表示 ??
> > $this->load->view('customer_edit_confirm', $data);
と書いたのはそのためで、もしそうだとすると
その前の
'cu_name' => $row->cu_name,
等も
'cu_name' => $this->input->post('cu_name'),
にする必要があります。
その場合余分な保護コード等を取っ払ってシンプルにすると
function edit($cu_id = '')
{
// 入力内容から $data を作成
$data = array(
'cu_name' => $this->input->post('cu_name'),
'cu_kana' => $this->input->post('cu_kana'),
'cu_tel' => $this->input->post('cu_tel'),
'cu_fax' => $this->input->post('cu_fax'),
'cu_mail' => $this->input->post('cu_mail'),
'biko' => $this->input->post('biko'),
'datetime'=> date('Y-m-d H:i:s', time()),
);
// $cu_id が数値のみになるように
$cu_id = (int) $cu_id;
// Where句の指定(対象)
$this->db->where('cu_id', $cu_id);
// 入力内容の edit を比較して処理を分岐
$edit = (int) $this->input->post('edit');
if ($edit == 1)
{
// 既存のレコードがある場合は更新
$this->db->update('customer', $data);
// 編集終了の表示
$this->load->view('customer_edit_finished');
}
else
{
// 編集確認画面を表示
$this->load->view('customer_edit_confirm', $data);
}
}
こんな感じになるかな。
--
木下敏夫
mailto:kino****@tktoo*****
http://www.tktools.jp/
http://okusama-shop.com/
http://www.oidc.jp/bmb/index.php?topic=-m-D14
-------------------------------------------------------------------------
ビジネスマッチングブログ・キックオフセミナーにパネリストとして参加します。
http://www.oidc.jp/bmb/article.php/20080207143305526
-------------------------------------------------------------------------