我有带选项的表格,当我要添加时,该值为null。我想问的是如何获得我选择的价值?
我的表格:
<select name="student_id" class="form-control" data-validate="required" id="student_id"
data-message-required="<?php echo get_phrase('value_required');?>"
onchange="return get_class_sections(this.value)">
<option value=""><?php echo get_phrase('Selectează_un_student');?></option>
<?php
$stare='0';
$classes = $this->db->get_where('disertatie_studenti',array('retrasi'=>$stare))->result_array();
foreach($classes as $row):
?>
<option value="<?php echo $this->db->get_where('disertatie_studenti' , array('student_id' => $row['student_id']))->row()->name;?>">
<?php echo $row['name'];?>
</option>
<?php
endforeach;
?>
</select>
我的控制器
$data['student_id'] = $this->input->post("student_id");
错误消息:
INSERT INTO `disertatie_corectura` (`student_id`, `corectura`, `timestamp`, `year`) VALUES (NULL, '2554', 1574456889, '2019-2020')
答案 0 :(得分:-1)
<option value="<?php echo $this->db->get_where('disertatie_studenti' , array('name' => $row['name']))->row()->student_id;?>">
<?php echo $row['name'];?>