我在单击复选框时接受和拒绝一些数据。从我的代码中接受代码运行良好,但拒绝是相同类型的代码,但运行不正常。
我的查看页面代码:
<form class="form-horizontal" method="POST" action="<?=site_url('Request/Update_Event')?>">
<div class="panel panel-flat" id="id">
<div class="panel-heading">
<center> <h4 class="panel-title">Request Portal</h4></center>
</div> <button type="submit" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-thumbs-up"></span>Approved
</button> <a href="<?=site_url('Request/Rejected')?>" class="btn btn-info btn-lg" id="but">
<span class="glyphicon glyphicon-thumbs-down"></span> Rejected
</a><div>
我的控制器代码:
public function Update_Event(){
$empid = $this->input->post('empid');
for($i=0; $i< sizeof($empid); $i++)
{
$data = array(
'backgroundColor' => 'green',
'event_status' =>'Approved',
);
$this->db->where(empid,$empid[$i]);
$this->db->update('events',$data);
}
redirect('Request','refresh');
}
public function Rejected(){
$empid = $this->input->post('empid');
for($i=0; $i< sizeof($empid); $i++)
{
$data = array(
'backgroundColor' => 'red',
'event_status' =>'Rejected',
);
$this->db->where(empid,$empid[$i]);
$this->db->update('events',$data);
}
redirect('Request','refresh');
print_r($empid);
}
我的表代码:
<table id="tb2" class="table datatable-responsive" >
<thead><tr><h6><th></th><th align="center">Name</th>
<th class="col-sm" >Leave Date</th>
<th class="col-sm" >Reason</th>
</tr></thead>
<?php foreach ($query as $row): ?>
<tr><td><input type="checkbox" name="empid[]" value="<?php echo $row['empid'];?>"></td>
<td>Leave Applied By <?php echo $row['first_name'];?> <?php echo $row['last_name'];?></td>
<td><?php echo date('d/m/Y', strtotime($row['event_date']));?></td>
<td><?php echo $row['title'];?> </td>
</tr></tbody><?php endforeach ?>
</table>
被拒绝的代码在我的代码中不起作用,并且当我打印 empid 值时,empid 没有传递给被拒绝的代码