1. こんにちは、私は codeigniter を初めて使用します。ID からコントローラー、モデルにデータを渡したいのですが、助けてください。
public function itemdetails(){
$id = $_REQUEST['id'];
$this->db->WHERE('assetTag', $id);
$query = $this->db->get('mis_inventory');
foreach ($query->result_array() as $row);
echo "<table border='1'>";
echo 'ASSET TAG';
echo strtoupper($row['assetTag']);
echo 'ITEM TYPE';
echo $row['itemType'];
echo 'BRAND';
echo $row['brand'];
echo 'MODEL';
echo $row['model'];
echo 'SERIAL';
echo $row['serial'];
echo anchor('main/update_item?id='. ucwords($row['assetTag']), 'EDIT');
2.次に、[編集]をクリックすると、以下のコントローラーコードにリダイレクトされます
public function update_item(){
if ($this->session->userdata('is_logged_in')){
$this->load->model('model_items');
$this->load->view('update');
}
}
3.その後、モデルに戻ります
public function update_item(){
$id = $_REQUEST['id'];
$this->db->WHERE('assetTag', $id);
$query = $this->db->get('mis_inventory');
foreach ($query->result_array() as $row);
echo form_open('main/update_validation');
echo "<table border='1'>";
echo 'ASSET TAG';
echo strtoupper($row['assetTag']);
echo 'ITEM TYPE';
echo form_input('itemType', $row['itemType']);
echo 'BRAND';
echo form_input('itemType', $row['brand']);
echo 'MODEL';
echo form_input('itemType', $row['model']);
echo 'SERIAL';
echo form_submit('submit', 'UPDATE');
echo validation_errors();
4.検証コードの更新
public function update_validation(){
$this->load->library('form_validation');
$this->load->model('model_items');
$id = $_REQUEST['id'];
$this->form_validation->set_rules('itemType', 'itemtype', 'required');
$this->form_validation->set_rules('brand', 'brand', 'required');
$this->form_validation->set_rules('model', 'model', 'required');
$this->form_validation->set_rules('serial', 'serial', 'required');
$this->form_validation->run();
$this->model_items->can_update_item();
echo $this->db->affected_rows().' record updated';
/** ID をクリックしたときにデータベース上の項目を編集したいだけです。値はフォーム TAG 内にある必要があり、コンテンツを編集して更新ボタンをクリックしますが、失敗しました。私はひどく助けが必要です。ありがとう **/