こんにちはみんな私は私が更新する必要があるフィールドを持つ次のモデルを持っています:
public function admin_add_review( $review = array()){
$data = array(
'title' => $review['title'],
'description' => $review['description'],
'category' => $review['category']
);
$query = $this->db->update('reviews', $data);
if( $query){
return true;
}else{
return false;
}
}
次のコントローラー、ここではデータをビューに送信します。
public function admin_validation()
{
$this->load->library('form_validation');
$this->load->model('model_users');
$review['title'] = $this->input->post('title');
$review['description'] = $this->input->post('description');
$review['category'] = $this->input->post('category');
$this->model_users->admin_add_review( $review );
$this->load->view('admin_page', $review);
}
および次のビュー。これはコントローラーから取得したデータを含むフォームであり、このデータを更新すると、内部の同じ説明でホールテーブルが更新されます。
<?php
$review = $review[0];
echo form_open_multipart('main/admin_validation');
echo validation_errors();
/*echo "<p> Id review</p>";
$data = array(
"name" => "id",
"value" => $review['id']
);
echo form_input($data);*/
echo "<h3>Title: ";
echo "</h3>";
$data = array(
"name" => "title",
"id" => "title-input",
"value" => $review['title']
);
echo form_input($data);
echo "<h3>Category: ";
echo "</h3>";
$data = array(
"name" => "category",
"id" => "category-input",
"value" => $review['category']
);
echo form_input($data);
echo "<h3>Description: ";
echo "</h3>";
$data = array(
"name" => "description",
"id" => "description",
"value" => $review['description']
);
echo form_textarea($data);
echo "<br/>";
echo "<br/>";
echo form_submit('login_submit', 'Update review.');
echo form_close();
?>
When i press the update button it updates all my database table rows! and i just want only the specified one to be updated. Help please.