我有一个包含表格值的数组。当var_dumped时,它还显示数组中的预期值。但是当它被回显时,最后一个数组中的值会被回显。如何回显数组中存在的所有值。我的观点如下:
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group">
<label>Appoinment Date</label>
<?php $attributes = array("name" => "Subscriptions add");
echo form_open("Admin/show_appoinment", $attributes);?>
<div class="input-group date">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div> <input type="hidden" name="chair" value="1">
<input type="date" name="n1" id="n1" class="form-control" value="<?php echo set_value('n1'); ?>" onChange="copy();">
</div>
</div> </div>
<div class="col-md-6 " style="margin-top:25px;">
<input type="submit" class="btn btn-sm btn-info ">
</div>
<?php echo form_close(); ?>
</div>
<?php $temp_array=[]; foreach($list as $row){array_push($temp_array, $row['time'], $row['op_no']); } ?>
<?php $attributes = array("name" => "Subscriptions add");
echo form_open("Admin/Add_Appointment", $attributes);?>
<?php $check=9.30; if(in_array($check, $temp_array)){
?>
<tbody id="table1">
<tr>
<td class="bg-danger"><input type="text" name="time" class="form-control" id="Dept_Id" value="9.30" readonly></td>
<td class="bg-danger"><input type="text" class="form-control" value=" <?php echo $row['op_no']; ?> " readonly></td>
<td class="bg-danger"><input type="text" class="form-control" value="<?php echo $row['p_name'];?>" readonly> </td>
<td class="bg-danger"><input type="text" class="form-control" value="<?php echo $row['name'];?>" readonly> </td>
<td class="bg-danger"><input type="button" value="Booked" class="btn btn-sm btn-danger glyphicon col-sm-offset-0">
<a href="<?php echo base_url('Admin/cancel_booking/'.$row['op_no'].'/'.$row['appointment_id']); ?>"> <input type="button" value="Cancel" name="s1" class="btn btn-sm btn-warning glyphicon col-sm-offset-0"></a></td>
<?php } else{?>
<td class="bg-success">
<input type="hidden" name="chair" value="1">
<input type="hidden" name="date" id="n2" value="<?php echo set_value('n1');?>"/>
<input type="text" class="form-control" class="form-control" name="time" id="Dept_Id" value="9.30" readonly></td>
<td class="bg-success"><input type="text" class="form-control" name="op_no" id="op_no" value="" ></td>
<td class="bg-success"><select name="p_name" class="form-control" type="text" id="p_name"/>
<option></option>
<?php
foreach($patient->result() as $row)
{
echo '<option value="'.$row->patient_id.'">'.$row->p_name.'</option>';
}
?>
</select></td>
<td class="bg-success"><select class="form-control" name="dr_name" type="text" id="dr_name"/>
<option></option>
<?php
foreach($chair->result() as $row)
{
echo '<option value="'.$row->user_id.'">'.$row->name.'</option>';
}
?></select></td>
<td class="bg-success">
<input type="submit" value="Booking" class="btn btn-sm btn-info glyphicon col-sm-offset-0"></td>
<?php } ?>
</tr>
<?php echo form_close(); ?>
我的控制器:
public function show_appoinment()
{
$date=$this->input->post('n1');
$chair=$this->input->post('chair');
$data['list']=$this->Appointment_model->get_appointment_by_date($date,$chair);
$data['chai'] =$this->Appointment_model->getdoctors_chair();
$data['chair'] =$this->Appointment_model->getdoctors_chair1($date);
$data['chairs'] =$this->Appointment_model->getdoctors_chair2($date);
$data['patient'] =$this->Appointment_model->getpatient();
$count['alert_count'] = $this->Stock_model->get_stock_for_alert_msg();
$this->load->view('Admin/header', $count);
if($data['list']){ //var_dump($data['list']); die();
$this->load->view('Admin/time_slot_view',$data);
}
else{
$this->load->view('Admin/time_slot_view2',$data);
}
$this->load->view('Admin/footer');
}
我的问题是:如果我在数组中从db中获取了两行,当我尝试回显这些数据时,最后一行中的一行反复回应。我怎么能解决这个问题......请帮助。