我正在尝试返回从存储在数据库中的数据动态创建的页面。但是,当我尝试返回主动态页面时,它不起作用。它应该提交重定向到共享轨道的码ID的页面。相反,它只是给我一个失败的消息
控制器
public function update_track($yard_id)
{
$data = array(
'track_id'=>$this->input->post('track_id'),
'train_id'=>$this->input->post('train_id'),
'train_direction'=>$this->input->post('train_direction'),
'train_length' =>$this->input->post('train_length'),
'train_hpt'=>$this->input->post('train_hpt'),
'train_tons'=>$this->input->post('train_tons'),
'train_status'=>$this->input->post('train_status'),
);
$this->load->model('atisyard_model');
$this->atisyard_model->update_track($data);
if($this->db->affected_rows()>0)
{
redirect('/atis/'.$value->yard_id);
}
else
{
echo 'failure';
}
}
查看
<?=form_open('atis/update_track/'); foreach ($record as $value) {?>
<h1>Edit Track:</h1>
<b><p>Track Name: </b><?php echo $value->track_no;?></br>
<b>Track Length: </b><?php echo $value->track_length;?>'</br></br></p>
<table cellpadding="5" border="0" align="center">
<input type="hidden" name="track_id" title="track_id" value="<?php echo $value->track_id;?>">
<tr>
<td>Lead Engine No. / Symbol / Work Order:</td>
<td><input type="text" name="train_id" id="train_id" size="28" maxlength="28" value="<?php echo $value->train_id;?>"></td>
</tr>
<tr>
<td>Train Direction:</td>
<td><?=form_dropdown('train_direction', $train_direction, $value->train_direction);?></td>
</tr>
<tr><td>Train Length:</td>
<td><input type="text" name="train_length" id="train_length" size="4" maxlength="6" value="<?php echo $value->train_length;?>"></td>
</tr>
<tr><td>HP/T:</td>
<td><input type="text" name="train_hpt" id="train_hpt" size="2" maxlength="5" value="<?php echo $value->train_hpt;?>"></td>
</tr>
<tr><td>Train Tons:</td>
<td><input type="text" name="train_tons" id="train_tons" size="4" maxlength="6" value="<?php echo $value->train_tons;?>"></td>
</tr>
<td>Train Status:</td>
<td> <?=form_dropdown('train_status', $train_status, $value->train_status);?></td>
</tr>
<tr>
<tr><td><button id="submitbtn" >Submit</button></td></tr>
</table>
<a href="<?=site_url("atis/yard/{$value->yard_id}");?>">Back to Yard</a>
<?php } echo form_close();?>
答案 0 :(得分:0)
如果我理解正确并且你将$ yard_id传递给你的update_track()函数,那么不应该这样:
redirect('/atis/'.$value->yard_id);
只是:
redirect('/atis/'.$yard_id);
因为我无法看到你从哪里获得$。
答案 1 :(得分:0)
再看一下你的代码,将yard_id添加为你表单上的隐藏字段会更好:
<input type="hidden" name="yard_id" name ="<?=$value->yard_id; ?>" />
然后将您的重定向更改为:
redirect('/atis/'.$this->input->post('yard_id'));