Ich baue meine Website, aber es gibt einige Probleme, zuerst, die ich nicht in die Datenbank einfügen kann.codeigniter Kann Feld nicht in Datenbank einfügen
Ich habe versucht, es zu tun, aber es funktioniert nicht.
jede mögliche Hilfe bitte
in controllers/cases.php
function add(){
\t \t $data['fields_clients'] = $this->custom_field_model->get_custom_fields(1);
\t \t $data['fields'] \t \t \t = $this->custom_field_model->get_custom_fields(2);
\t \t $data['clients'] \t \t = $this->cases_model->get_all_clients();
\t \t $data['stages'] \t \t = $this->case_stage_model->get_all();
\t \t $data['acts'] \t \t \t = $this->cases_model->get_all_acts();
\t \t $data['courts'] \t \t \t = $this->cases_model->get_all_courts();
\t \t $data['locations'] \t \t = $this->cases_model->get_all_locations();
\t \t $data['case_categories'] = $this->cases_model->get_all_case_categories();
\t \t $data['court_categories']= $this->cases_model->get_all_court_categories();
$data['city'] = $this->cases_model->get_name_city();
//$data['employee'] = $this->cases_model->get_name_employee();
\t \t if ($this->input->server('REQUEST_METHOD') === 'POST')
{ \t
\t \t \t $this->load->library('form_validation');
\t \t \t $this->form_validation->set_message('required', lang('custom_required'));
\t \t \t $this->form_validation->set_rules('title', 'lang:title', 'required');
\t \t \t $this->form_validation->set_rules('client_id', 'Client', '');
\t \t \t $this->form_validation->set_rules('case_no', 'Case No', ''); //trim|required|is_unique[cases.case_no]
\t \t \t $this->form_validation->set_rules('location_id', 'Location', '');
\t \t \t $this->form_validation->set_rules('case_stage_id', 'Case Stage', '');
\t \t \t $this->form_validation->set_rules('court_id', 'Court', '');
\t \t \t $this->form_validation->set_rules('court_category_id', 'Court Category', '');
\t \t \t $this->form_validation->set_rules('case_category_id', 'Case Category', '');
\t \t \t $this->form_validation->set_rules('act_id', 'Act', '');
\t \t \t $this->form_validation->set_rules('start_date', 'Filing Date', '');
\t \t \t $this->form_validation->set_rules('description', 'Description', '');
\t \t \t $this->form_validation->set_rules('city_case', 'city case', '');
\t \t \t $this->form_validation->set_rules('fees', 'Fees', '');
\t \t \t $this->form_validation->set_rules('o_lawyer', 'Opposite Lawyer', '');
\t \t \t $this->form_validation->set_rules('hearing_date', 'Description', '');
\t \t \t
\t \t \t if ($this->form_validation->run()==true)
{
\t \t \t \t $save['title'] = $this->input->post('title');
\t \t \t \t $save['case_no'] = $this->input->post('case_no');
\t \t \t \t $save['client_id'] = $this->input->post('client_id');
\t \t \t \t $save['location_id'] = $this->input->post('location_id');
\t \t \t \t $save['court_id'] = $this->input->post('court_id');
\t \t \t \t $save['court_category_id'] = $this->input->post('court_category_id');
\t \t \t \t $save['case_stage_id'] = $this->input->post('case_stage_id');
\t \t \t \t $save['case_category_id'] = json_encode($this->input->post('case_category_id'));
\t \t \t \t $save['act_id'] = json_encode($this->input->post('act_id'));
\t \t \t \t $save['description'] = $this->input->post('description');
\t \t \t \t $save['start_date'] = $this->input->post('start_date');
\t \t \t \t $save['hearing_date'] = $this->input->post('hearing_date');
\t \t \t \t $save['o_lawyer'] = $this->input->post('o_lawyer');
\t \t \t \t $save['fees'] = $this->input->post('fees');
\t \t \t \t $save['city_case'] = json_encode($this->input->post('city_case'));
\t \t \t \t $p_key = $this->cases_model->save($save);
\t \t \t \t $reply = $this->input->post('reply');
\t \t \t \t \t if(!empty($reply)){
\t \t \t \t \t foreach($this->input->post('reply') as $key => $val) {
\t \t \t \t \t \t $save_fields[] = array(
\t \t \t \t \t \t \t 'custom_field_id'=> $key,
\t \t \t \t \t \t \t 'reply'=> $val,
\t \t \t \t \t \t \t 'table_id'=> $p_key,
\t \t \t \t \t \t \t 'form'=> 2,
\t \t \t \t \t \t); \t
\t \t \t \t \t
\t \t \t \t \t } \t
\t \t \t \t \t $this->custom_field_model->save_answer($save_fields);
\t \t \t \t }
\t \t \t \t
$this->session->set_flashdata('message', lang('case_created'));
\t \t \t \t redirect('admin/cases');
\t \t \t
\t \t \t \t
\t \t \t }
\t \t } \t \t
\t \t
\t \t
\t \t $data['page_title'] = lang('add') . lang('case');
\t \t $data['body'] = 'case/add';
\t \t
\t \t
\t \t $this->load->view('template/main', $data); \t
\t } \t
in view/add.php
<select name="city_case[]" class="chzn col-md-12" multiple="multiple" >
\t \t \t \t \t \t \t \t \t <option value="">--<?php echo lang('select_city')?>--</option>
\t \t \t \t \t \t \t \t \t <?php foreach($city as $new) {
\t \t \t \t \t \t \t \t \t \t \t $sel = "";
\t \t \t \t \t \t \t \t \t \t \t if(set_select('city_case', $new->id)) $sel = "selected='selected'";
\t \t \t \t \t \t \t \t \t \t \t echo '<option value="'.$new->id.'" '.$sel.'>'.$new->name.'</option>';
\t \t \t \t \t \t \t \t \t \t }
\t \t \t \t \t \t \t \t \t \t
\t \t \t \t \t \t \t \t \t \t ?>
\t \t \t \t \t \t \t \t \t </select>
models/cases_model.php
function get_name_city()
\t {
\t $query = $this->db->get ('user_role');
\t return $query->result();
\t }
ich ersetzen Code von add.php mit einem anderen Code, er arbeitet nette
- - id)) $ sel = " ausgewählt = 'ausgewählt' "; echo 'id'“‘. $ Sel. '> '' $ Neuen-> Namen..'; }
?>
</select>
tun das Tutorial in der Codeigniter Handbuch wird es die meisten Ihrer Fragen beantworten einschließlich alles über das Einfügen in eine Datenbank. Als nächstes - wenn Sie etwas Neues bauen - fangen Sie einfach an und bauen Sie dann aus. Wie in diesem Fall starten Sie mit nur ein paar Formularfeldern. mach das funktionieren. füge dann den Rest der Felder hinzu. es ist viel schneller, Fehler auf diese Weise zu finden. – cartalot