|
我的view的代码
<?php foreach($data as $item):?>
<tr>
<td><?php echo $item->ID;?></td>
<td><?php echo $item->name;?></td>
<td><?php echo $item->email;?></td>
<td><?php echo $item->text;?></td>
<td><a href="<?php echo site_url('editboard/show/ID/'.$item->ID)?>" >编辑</a>
<a href="<?php echo site_url('deleteboard/delete/ID/'.$item->ID)?>" >删除</a></td>
</tr>
<?php endforeach;?>
控制器代码:(删除功能)
public function delete()
{
$params = $this->uri->uri_to_assoc();
if (!empty($params['ID']) && $params['ID'] > 0)
{
$ID = $params['ID'];
$this->load->model('boardmodel');
$this->boardmodel->ID=$ID;
$this->boardmodel->delete_data();
$data['query'] = $this->boardmodel->get_last_ten_entries();
$this->load->view('boardview', $data);
}
else
{
$this->load->model('boardmodel');
$data['query'] = $this->boardmodel->get_last_ten_entries();
$this->load->view('boardview', $data);
}
模型代码:
var $ID='';
var $name = '';
var $email = '';
var $text = '';
function delete_data()
{
$this->ID = $_POST['ID'];
$this->db->where('ID', $this->ID);
$this->db->delete('board');
}
}
错误提示:
A PHP Error was encounteredSeverity: Notice
Message: Undefined index: ID
Filename: models/boardmodel.php
Line Number: 36
说我 ID无效 本人很菜 看了半天 不知道问题在哪 故来发帖 请高手赐教!谢谢!
|
|