我想推廣一批學生從第一學期到第二學期。如何將一批學生從一學期推廣到另一學期?
---------------控制器-------------- ------
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);
}
------------------------- views ------------------- -----
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">
\t \t \t \t <select class="form-control" name="course" required>
\t \t \t \t <option>--Choose a Course--</option>
<?php
foreach($course as $row)
{
echo '<option value="'.$row->course_id.'">'.$row->c_name.'</option>';
}?>
\t \t \t \t </select>
<span class="text-danger"><?php echo form_error('course'); ?></span>
</div>
\t \t \t \t </div>
\t \t \t
\t <div class="form-group has-feedback">
<label for="semester" class="col-sm-2 control-label" placeholder="">Semester</label>
<div class="col-sm-6">
\t \t \t \t
<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>';
}?>
\t \t \t </select>
<span class="text-danger"><?php echo form_error('semester'); ?></span>
</div>
\t \t \t \t </div>
\t \t \t \t <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>
List_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">
\t \t <table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Serial no</th>
\t \t \t \t <th>Student Name</th>
<th>Course</th>
\t \t \t \t <th>Semester</th>
\t \t \t \t <th>Batch</th>
</tr>
</thead>
\t \t \t \t <tbody>
<?php
$i=1; \t \t
foreach ($promote as $row)
{
?>
<tr>
\t \t \t \t <td><?php echo $i++;?></td>
\t \t \t \t <td><?php echo $row['stud_name'];?></td>
\t \t \t \t <td><?php echo $row['c_name'];?></td>
\t \t \t \t <td><?php echo $row['sem_code'];?></td>
\t \t \t \t <td><?php echo $row['batch_year'];?></td> \t
\t \t \t \t </tr>
\t <?php }
?>
</tbody>
</table>
<?php $attributes = array("name" => "update");
echo form_open("Admin/promote_semester_processing", $attributes);?>
\t \t <input type="hidden" value="<?php echo $course;?>" name="course"/>
\t \t <input type="hidden" value="<?php echo $sem;?>" name="sem"/>
\t \t <input type="hidden" value="<?php echo $batch;?>" name="batch"/>
\t \t <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>
\t \t <button name="save" type="submit" class="btn btn-warning" >Promote Semester</button>
\t \t <?php echo form_close(); ?>
</div>
</div>
</div>
</div>
只有一個學生正在使用此代碼升遷。但是我想把一批學生提升到下一個學期。我怎麼做?
請儘早幫助我。
我認爲這是很重要的代碼。你能發佈最相關的行嗎? –
提示提問javascript,html,css不是php的運行代碼片段如果您需要添加代碼,您可以通過這種方式添加代碼https://meta.stackexchange.com/questions/22186/how-do-i-format-我的代碼塊 – user4419336