列“ class_id”不能为空

时间:2018-07-27 10:12:01

标签: php sql

我在仪表板上的学生晋升功能有问题,我很头晕,但还没有找到解决通知的解决方案:

  

错误号:1048列'class_id'不能为null INSERT INTO   enrollenroll_codestudent_idclass_idyear date_added)值('a18b241','254',NULL,'2019 -2020',1532682443)

     

文件名:C:/xampp/htdocs/sisnef/application/controllers/Admin.php

     

行号:860

<script type="text/javascript">

	$(document).ready(function() {
        if($.isFunction($.fn.selectBoxIt))
		{
			$("select.selectboxit").each(function(i, el)
			{
				var $this = $(el),
					opts = {
						showFirstOption: attrDefault($this, 'first-option', true),
						'native': attrDefault($this, 'native', false),
						defaultText: attrDefault($this, 'text', ''),
					};
					
				$this.addClass('visible');
				$this.selectBoxIt(opts);
			});
		}
    });
</script>
			<?php 
				$students = $this->db->get_where('enroll' , array(
					'class_id' => $class_id_from , 'year' => $running_year
				))->result_array();
				foreach($students as $row):
					$query = $this->db->get_where('enroll' , array(
						'student_id' => $row['student_id'],
							'year' => $promotion_year
						));
			?>
				<tr>
					
					<td align="center">
						<?php echo $this->db->get_where('student' , array('student_id' => $row['student_id']))->row()->name;?>
					</td>
					<td align="center">
						<?php if($row['section_id'] != '' && $row['section_id'] != 0)
								echo $this->db->get_where('section' , array('section_id' => $row['section_id']))->row()->name;
						?>
					</td>
					<td align="center"><?php echo $row['roll'];?></td>
					<td>
						<?php if($query->num_rows() < 1):?>
							<select class="form-control selectboxit" name="promotion_status_<?php echo $row['student_id'];?>" id="promotion_status">
								<option value="<?php echo $class_id_to;?>">
									<?php echo get_phrase('Promotion-to') ." - ". $this->crud_model->get_class_name($class_id_to);?>
								</option>
								<option value="<?php echo $class_id_from;?>">
									<?php echo get_phrase('Promotion-to') ." - ". $this->crud_model->get_class_name($class_id_from);?>
							</select>
						<?php endif;?>
						<?php if($query->num_rows() > 0):?>
							<center>
							<button class="btn btn-success">
								<i class="entypo-check"></i> <?php echo get_phrase('Already');?>
							</button>
							</center>
						<?php endif;?>
					</td>
				</tr>
			<?php endforeach;?>
			</tbody>
		</table>
	</div>
	</div>
</div>
<br>
<div class="row">
	<center>
		<button type="submit" class="btn btn-info">
			<i class="fa fa-check"></i> <?php echo get_phrase('Promotion-Selected');?>
		</button>
	</center>
</div>

<!-- begin snippet: js hide: false console: true babel: false -->

我真的希望为这种情况找到一个好的解决方案。谢谢

2 个答案:

答案 0 :(得分:0)

您需要为class_id定义一个值。

$class_id_from在哪里定义?确保已设置值。

答案 1 :(得分:0)

我可以在您的屏幕截图中看到

https://drive.google.com/file/d/1mFNH8TsdCjhUaFxGcgTw1dnHYyDl6ote/view

您必须

`class_id` varchar(20) NULL,

class_id可以为null,只需在表结构中将其声明为NULL

查看我的屏幕截图enter image description here