2015-03-10 4 views
-4
"", "стиль" => "высота: 450px; ширина: 350 пикселей; маржа налево: 10px; цвет фона: белый,"?))> Edit Property «> Описание: «>
Департамент > Кафедра английского языка > Математика Отдел > Филиппинский кафедра > Наука кафедра > Общественные науки кафедра > MAPEH Отдел > Компьютерный Dept. > Главная Экономика Dept. > Значения Dept.
Life Years: «>
Стоимость: «>
Офицер: ">
Количество:">
«БТН БТН-умолчанию»));?>
public function edit_prop(){ 
     $this->form_validation->set_rules('description','Description','required'); 
     $this->form_validation->set_rules('quantity','Quantity','required'); 
     $this->form_validation->set_rules('lifeyears','Life Years','required'); 
     $this->form_validation->set_rules('cost','Cost','required'); 
     $this->form_validation->set_rules('accountable_officer','Accountable Officer','required'); 

     if($this->form_validation->run() == false){ 
      if($this->properties->update_prop() == true){ 
       $this->session->set_flashdata('updated', 'Updated Successfully!'); 
       redirect('properties_controller/view_properties'); 
      } 
     } 
     else{ 
      $data = array(
        'id' => $this->input->post('id'), 
        'description' => $this->input->post('description'), 
        'accountable' => $this->input->post('accountable'), 
        'lifeyears' => $this->input->post('lifeyears'), 
        'cost' => $this->input->post('cost'), 
        'accountable_officer' => $this->input->post('accountable_officer'), 
        'quantity' => $this->input->post('quantity') 
       );    
       $data['design'] = 'update_property'; 
       $data['title'] = 'Properties Corner!'; 
       $this->load->view('template_dashboard',$data); 
     } 
+0

Так что ваш вопрос .. – Bora

+0

Убирать ваш код также и то, что ваше? проб Лем? – user4419336

ответ

0

Не удалось выяснить, что ваш после того как я думаю, что вы пытаетесь сделать что-то вроде кода ниже.

Порекомендуйте сначала о своем вопросе в следующий раз.

всего лишь примеры

Также проверьте вы установили свои маршруты и в форме использования действий

$routes['controller_name'] = "controller_name/index"; 
$routes['controller_name/add'] = "controller_name/add"; 
$routes['controller_name/edit/(:any)'] = "controller_name/edit/$1"; 

Читать Руководство пользователя.http://localhost/project/something/edit/1 $this->uri->segment(what_your_id_is_in_url);

Просмотр Форма

action="<?php echo base_url('controller_name/edit' .'/'. $this->uri->segment(3));?>" 

Пример:

<?php 

class Controller_name extends CI_Controller { 

public function index() { 

    if ($this->uri->segment(3) == TRUE) { 
    $this->edit_prop(); 
    } else { 
    $this->add_prop(); 
    } 
} 

public function add_prop() { 
} 

public function edit_prop(){ 

$this->load->library('form_validation'); 

$data['design'] = 'update_property'; 
$data['title'] = 'Properties Corner!'; 

$this->form_validation->set_rules('description','Description','required'); 
$this->form_validation->set_rules('quantity','Quantity','required'); 
$this->form_validation->set_rules('lifeyears','Life Years','required'); 
$this->form_validation->set_rules('cost','Cost','required'); 
$this->form_validation->set_rules('accountable_officer','Accountable Officer','required'); 

if($this->form_validation->run() == false){ 

$this->load->view('template_dashboard', $data); 

} else { 

$this->load->model('model_name'); 

$id = $this->uri->segment(3); // Read User Guide. http://localhost/project/something/edit/1 $this->uri->segment(what_your_id_is_in_url); 

$this->model_name->edit($id); 

$this->session->set_flashdata('updated', 'Updated Successfully!'); 
redirect('properties_controller/view_properties'); 

} 

} 

Модель

class Model_name extends CI_Model { 

public function edit($id) { 
    $data = array(
     'id' => $this->input->post('id'), 
     'description' => $this->input->post('description'), 
     'accountable' => $this->input->post('accountable'), 
     'lifeyears' => $this->input->post('lifeyears'), 
     'cost' => $this->input->post('cost'), 
     'accountable_officer' => $this->input->post('accountable_officer'), 
     'quantity' => $this->input->post('quantity') 
    );  

    $this->db->where('id', $id); 
    $this->db->update('table_name', $data);  

} 
} 
Смежные вопросы