Значение элемента не обновляется, CodeigniterPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Значение элемента не обновляется, Codeigniter

Сообщение Anonymous »

Я новичок в использовании codeigniter и пытаюсь обновить значение элемента в своей базе данных, но это не работает. Я не могу понять, что делать, потому что когда я нажимаю кнопку "Сохранить", страница перенаправляется на /packages(где отображается список пакетов), но элемент не обновляется. Вот мой контроллер
public function update_package($id)
{
$this->form_validation->set_rules('title', 'Package Name', 'required');
$this->form_validation->set_rules('tour_location', 'Inclusions', 'trim');
$this->form_validation->set_rules('description', 'Description', 'trim|required');
$this->form_validation->set_rules('cost', 'Price', 'required');
$this->form_validation->set_rules('status', 'Status', 'required');

if ($this->form_validation->run() == true) {
$current_image = $this->input->post('current_image');
$new_image = $_FILES['image']['name'];

if ($new_image == TRUE) {

$update_image = time() . "-" . str_replace(' ', '-', $_FILES['image']['name']);
$config = [
'upload_path' => './images',
'allowed_types' => 'gif|jpg|png',
'file_name' => $update_image,
];

$this->load->library('upload', $config);

if (!$this->upload->do_upload('image')) {
if (file_exists('./images' . $current_image)) {
unlink('./images' . $current_image);
}
}
} else {
$update_image = $current_image;
}

$packageData = array(
'title' => $this->input->post('title'),
'tour_location' => $this->input->post(htmlentities('tour_location')),
'description' => $this->input->post(htmlentities('description')),
'cost' => $this->input->post('cost'),
'status' => $this->input->post('status'),
'upload_path' => $update_image
);

$img = new Admin_model;
$img->update($packageData, $id);
$this->session->set_flashdata('status', 'Package InsertedSuccesfully');
redirect(base_url('admin/edit_package/'.$id));
} else {
return $this->edit_package($id);
}
}

Моя модель
public function update($data, $id) {
// Update member data
return $this->db->update("packages", $data ,array('id' => $id));
}

Просмотр





Description


Price
>Active


Подробнее здесь: https://stackoverflow.com/questions/721 ... odeigniter
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»