我的数据库ID为1,2,4(img-1) 但如果我尝试更新id_bank = 1,我得到404错误(img-2) 但该更新使用另一个id(img-3) 昨天这个应用工作正常,但今天早上我收到了这个错误,我不知道为什么,我真的需要帮助:(
更新: 我使用codeigniter框架, 这是我的控制器代码
function form($id_bank = false)
{
$this->id_bank = $id_bank;
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$data['page_title'] = lang('bank_form');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => lang('home'),
'href' => base_url()
);
$data['breadcrumbs'][] = array(
'text' => lang('bank_form'),
'href' => base_url('bank')
);
//default values are empty if the provinsi is new
$data['id_bank'] = '';
$data['nama_bank'] = '';
$this->form_validation->set_rules('nama_bank', 'lang:nama_bank', 'trim|required|max_length[64]');
//$this->form_validation->set_rules('id_categories', 'lang:id_categories', 'trim|required|max_length[64]');
// validate the form
if ($this->form_validation->run() == FALSE)
{
$this->view('bank/form', $data);
}
else
{
if (!$this->auth->hasPermission('modify', 'bank'))
{
$this->session->set_flashdata('error', lang('error_acces'));
redirect('bank');
}
$this->load->helper('text');
$save['id_bank'] = $id_bank;
$save['nama_bank'] = $this->input->post('nama_bank');
$this->Model_bank->save_provinsi($save);
$this->session->set_flashdata('message', lang('message_provinsi_saved'));
//go back to the category list
redirect('bank');
}
}
function form($id_bank = false)
{
$this->id_bank = $id_bank;
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">', '</div>');
$data['page_title'] = lang('bank_form');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => lang('home'),
'href' => base_url()
);
$data['breadcrumbs'][] = array(
'text' => lang('bank_form'),
'href' => base_url('bank')
);
//default values are empty if the provinsi is new
$data['id_bank'] = '';
$data['nama_bank'] = '';
$this->form_validation->set_rules('nama_bank', 'lang:nama_bank', 'trim|required|max_length[64]');
//$this->form_validation->set_rules('id_categories', 'lang:id_categories', 'trim|required|max_length[64]');
// validate the form
if ($this->form_validation->run() == FALSE)
{
$this->view('bank/form', $data);
}
else
{
if (!$this->auth->hasPermission('modify', 'bank'))
{
$this->session->set_flashdata('error', lang('error_acces'));
redirect('bank');
}
$this->load->helper('text');
$save['id_bank'] = $id_bank;
$save['nama_bank'] = $this->input->post('nama_bank');
$this->Model_bank->save_provinsi($save);
$this->session->set_flashdata('message', lang('message_provinsi_saved'));
//go back to the category list
redirect('bank');
}
}
这是我的看法
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th><?php echo lang('no');?></th>
<th><?php echo sort_url('nama_bank', 'nama_bank', $order_by, $sort_order, $code);?></th>
<th><?php echo sort_url('gambar', 'image', $order_by, $sort_order, $code);?></th>
<th class="text-center"><?php echo lang('action');?></th>
</tr>
</thead>
<tbody>
<?php echo (count($type) < 1)?'<tr><td style="text-align:center;" colspan="5">'.lang('no_type').'</td></tr>':''?>
<?php
$pages = ($page-1)*10;
foreach ($type as $merks):
$pages+=1;
?>
<tr>
<td style="width:10px;"><?php echo $pages; ?></td>
<td style=""><?php echo $merks->nama_bank; ?></td>
<td style="text-align:center"> <span><img width="50px" height="50px" src='<?php echo $this->config->item('url_image').'photo/bank/'.$merks->image?>'></span></td>
<td style="width:10%;" class="text-center">
<a href="<?php echo site_url('bank/form/'.$merks->id_bank); ?>" data-toggle="tooltip" title=" <?php echo lang('edit');?>" class="btn btn-sm btn-primary"><i class="fa fa-pencil"></i></a>
<?php if ($this->auth->hasPermission('delete', 'bank')) { ?>
<a href="<?php echo site_url('bank/delete/'.$merks->id_bank); ?>" data-toggle="tooltip" onclick="return areyousure();" title="<?php echo lang('delete');?>" class="btn btn-sm btn-danger"><i class="fa fa-trash-o"></i></a>
<?php } ?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
这在我的路线上:
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th><?php echo lang('no');?></th>
<th><?php echo sort_url('nama_bank', 'nama_bank', $order_by, $sort_order, $code);?></th>
<th><?php echo sort_url('gambar', 'image', $order_by, $sort_order, $code);?></th>
<th class="text-center"><?php echo lang('action');?></th>
</tr>
</thead>
<tbody>
<?php echo (count($type) < 1)?'<tr><td style="text-align:center;" colspan="5">'.lang('no_type').'</td></tr>':''?>
<?php
$pages = ($page-1)*10;
foreach ($type as $merks):
$pages+=1;
?>
<tr>
<td style="width:10px;"><?php echo $pages; ?></td>
<td style=""><?php echo $merks->nama_bank; ?></td>
<td style="text-align:center"> <span><img width="50px" height="50px" src='<?php echo $this->config->item('url_image').'photo/bank/'.$merks->image?>'></span></td>
<td style="width:10%;" class="text-center">
<a href="<?php echo site_url('bank/form/'.$merks->id_bank); ?>" data-toggle="tooltip" title=" <?php echo lang('edit');?>" class="btn btn-sm btn-primary"><i class="fa fa-pencil"></i></a>
<?php if ($this->auth->hasPermission('delete', 'bank')) { ?>
<a href="<?php echo site_url('bank/delete/'.$merks->id_bank); ?>" data-toggle="tooltip" onclick="return areyousure();" title="<?php echo lang('delete');?>" class="btn btn-sm btn-danger"><i class="fa fa-trash-o"></i></a>
<?php } ?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>