[eluser]Unknown[/eluser]
I need to pass the id field value to a delete link. This way the whole row will be deleted.
Any help is much appreciated. Thanks.
controller code:
Code:
function delete_record($id){
$this->load->model('records');
$id = array('id'=>$this->uri->segment(3));
$this->records->delete_data($id);
}
model code:
Code:
function delete_data($id){
$this->db->where('id',$id);
if($this->db->delete("users")){
return true;
} else return false;
}
view code:
Code:
<?php if(!empty($results)):?>
<?php foreach($results as $row):?>
<?php
echo $row->id;
echo ' | ';
echo $row->name;
echo ' | ';
echo $row->email;
echo ' | ';
?>
<a href='<?php echo site_url("index.php/home/delete_record", $row->$id)?>'>Delete</a>
<?php echo '<br/>';?>
<?php endforeach?>
<?php endif ?>