Php 如何获取所选选项值(codeigniter)
我有带选项的表单,当我想添加时,值为空。我想问的是如何获得我选择的值 我的表格:Php 如何获取所选选项值(codeigniter),php,codeigniter,controller,Php,Codeigniter,Controller,我有带选项的表单,当我想添加时,值为空。我想问的是如何获得我选择的值 我的表格: <select name="student_id" class="form-control" data-validate="required" id="student_id" data-message-required="<?php echo get_phrase('value_required');?>"
<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>
错误消息:
INSERT INTO `disertatie_corectura` (`student_id`, `corectura`, `timestamp`, `year`) VALUES (NULL, '2554', 1574456889, '2019-2020')
您不认为最好在
标记之前运行查询,然后echo
您检查的值您在foreach上检索正确的值吗?
INSERT INTO `disertatie_corectura` (`student_id`, `corectura`, `timestamp`, `year`) VALUES (NULL, '2554', 1574456889, '2019-2020')
<option value="<?php echo $this->db->get_where('disertatie_studenti' , array('name' => $row['name']))->row()->student_id;?>">
<?php echo $row['name'];?>