【发布时间】:2023-03-17 14:35:02
【问题描述】:
我想从第一学期提升一批学生到第二学期。
---------------控制器--------
public function display_promote_student()
{
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true && $_SESSION['role'] === '1' && $_SESSION['role_des'] === 'admin')
{
$data['batch']=$this->Student_model->get_all_batch();
$data['course']=$this->Student_model->get_all_course();
$data['sem']=$this->Student_model->get_all_sem();
if($data)
{
$this->load->view('Admin/header');
$this->load->view('Admin/promote_students', $data);
}
else
{
redirect('Admin/index','refresh');
}
}
else
{
redirect('Admin/index');
}
}
public function list_promote_student_view()
{
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true && $_SESSION['role'] === '1' && $_SESSION['role_des'] === 'admin')
{
$course=$this->input->post('course');
$sem=$this->input->post('sem');
$batch=$this->input->post('batch');
$data['course']=$course;
$data['sem']=$sem;
$data['batch']=$batch;
$data['promote'] = $this->Student_model->get_all_student_by_cour_sem($course,$sem,$batch);
$this->load->view('Admin/header');
$this->load->view('Admin/list_promote_students',$data);
}
}
public function promote_semester_processing()
{
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true && $_SESSION['role'] === '1' && $_SESSION['role_des'] === 'admin')
{
$course=$this->input->post('course');
$sem=$this->input->post('sem');
$batch=$this->input->post('batch');
$new_sem=$this->input->post('newsem');
$results = $this->Student_model->get_all_student_by_cour_sem($course,$sem,$batch);
$dep_id = [$results];
//var_dump( $dep_id);die();
$prodate = date('Y-m-d');
$month = strtotime($prodate);
$promonth = date('m',$month);
foreach($results as $val)
{
$dep_id = $val['student_id'];
$db_date = $val['promote_date'];
$db_month = strtotime($db_date);
$pro_month = date('m',$db_month);
$cal = $pro_month +5;
$data = array(
'sem_id' =>$new_sem,
'promote_date' =>$prodate);
if($db_date == 0)
{
$id=$this->Student_model->update_semester($dep_id,$data);
if($id)
{
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Promote Semester Successfully... </div>');
redirect('Admin/display_promote_student');
}
else
{
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">Promote Semester not Successfully... </div>');
redirect('Admin/display_promote_student');
}
}
elseif ($promonth == $cal)
{
$id=$this->Student_model->update_semester($dep_id,$data);
}
else
{
$this->session->set_flashdata('msg','<div class="alert alert-success text-center">You can promote only after six months... </div>');
redirect('Admin/display_promote_student');
}
}
}
}
-------型号----------
public function get_all_student_by_cour_sem($course,$sem,$batch)
{
$this->db->select( 'tbl_student.*, tbl_course.*,tbl_semester.*,tbl_batch.*');
$this->db->from('tbl_student');
$this->db->join('tbl_course','tbl_course.course_id = tbl_student.course_id','left');
$this->db->join('tbl_semester', 'tbl_semester.sem_id = tbl_student.sem_id','left');
$this->db->join('tbl_batch', 'tbl_batch.batch_id = tbl_student.stud_batch_id','left');
$this->db->where('tbl_student.course_id',$course);
$this->db->where('tbl_student.sem_id',$sem);
$this->db->where('tbl_student.stud_batch_id',$batch);
$query = $this->db->get();
return $query->result_array();
}
public function update_semester($dep_id,$data)
{
$this->db->where('student_id',$dep_id);
return $query = $this->db->update('tbl_student',$data);
}
--------------浏览量---------- ---
promote_student
<div class="container">
<div class="col-md-10 col-md-offset-1">
<h4><?php echo $this->session->flashdata('msg'); ?></h4><br>
<div class="panel panel-default">
<div class="panel-heading">
<h3>Promote Students</h3>
</div>
<?php $attributes = array("name" => "promote", "class" => "form-horizontal");
echo form_open_multipart("Admin/list_promote_student_view", $attributes);?>
<div class="panel-body">
<div class="form-group has-feedback">
<label for="title" class="col-sm-2 control-label">Course</label>
<div class="col-sm-6">
<select class="form-control" name="course" required>
<option>--Choose a Course--</option>
<?php
foreach($course as $row)
{
echo '<option value="'.$row->course_id.'">'.$row->c_name.'</option>';
}?>
</select>
<span class="text-danger"><?php echo form_error('course'); ?></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="semester" class="col-sm-2 control-label" placeholder="">Semester</label>
<div class="col-sm-6">
<select class="form-control" name="sem" required>
<option>--Choose a Semester--</option>
<?php
foreach($sem as $row)
{
echo '<option value="'.$row->sem_id.'">'.$row->sem_code.'</option>';
}?>
</select>
<span class="text-danger"><?php echo form_error('semester'); ?></span>
</div>
</div>
<div class="form-group has-feedback">
<label for="title" class="col-sm-2 control-label">Year</label>
<div class="col-sm-6">
<select class="form-control" name="batch" required>
<option>--Choose Batch--</option>
<?php
foreach($batch as $row)
{
echo '<option value="'.$row->batch_id.'">'.$row->batch_year.'</option>';
}?>
</select>
</div>
<span class="text-danger"><?php echo form_error('year'); ?></span>
</div>
</div>
<div class="box-footer col-md-offset-4">
<button type="submit" class="btn btn-warning">Submit</button>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
列出_promote_students
<div class="container">
<a href="<?php echo base_url('Admin/display_promote_student');?>" class="btn btn-warning btn-flat margin pull-right">Previous</a>
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">
<h3>Student List</h3>
</div>
<div class="panel-body">
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Serial no</th>
<th>Student Name</th>
<th>Course</th>
<th>Semester</th>
<th>Batch</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
foreach ($promote as $row)
{
?>
<tr>
<td><?php echo $i++;?></td>
<td><?php echo $row['stud_name'];?></td>
<td><?php echo $row['c_name'];?></td>
<td><?php echo $row['sem_code'];?></td>
<td><?php echo $row['batch_year'];?></td>
</tr>
<?php }
?>
</tbody>
</table>
<?php $attributes = array("name" => "update");
echo form_open("Admin/promote_semester_processing", $attributes);?>
<input type="hidden" value="<?php echo $course;?>" name="course"/>
<input type="hidden" value="<?php echo $sem;?>" name="sem"/>
<input type="hidden" value="<?php echo $batch;?>" name="batch"/>
<div class="form-group">
<label>Semester</label>
<select class="form-control" name="newsem" required data-placeholder="Semester">
<option>--Semester--</option>
<option value="1">s1</option>
<option value="2">s2</option>
<option value="3">s3</option>
<option value="4">s4</option>
<option value="5">s5</option>
<option value="6">s6</option>
</select>
</div>
<button name="save" type="submit" class="btn btn-warning" >Promote Semester</button>
<?php echo form_close(); ?>
</div>
</div>
</div>
</div>
只有一名学生使用此代码获得晋升。但我想提拔一批学生进入下学期。我该怎么做?
请尽早帮助我。
【问题讨论】:
-
我认为这是很多代码。你能只发布最相关的行吗?
-
提示询问运行代码sn-ps for javascript, html, css not php 如果你需要添加代码你可以这样添加meta.stackexchange.com/questions/22186/…
标签: php html css mysql codeigniter