Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14115

Cannot delete from database

$
0
0
I cannot delete using a button in a datatabe but I can delete if I use a form and I don't know what I'm doing wrong.

The form that works:

<?php echo form_open('/posts/delete/'.$post['id']); ?>
<input type="submit" value="Delete" class="btn btn-danger">
<?php echo form_close(); ?>

MY controller:

    public function delete($id){
        $this->post_model->delete_post($id);

        redirect('posts/latest_post');
    }

My model:

public function delete_post($id){

$this->db->where('id', $id);
$this->db->delete('posts');
return true;
}

My button in the datatable:

<td>
       <a class="btn btn-danger" type="button"  href="<?php echo base_url(); ?>posts/delete/<?php echo $post['id']; ?>"><i class="fa fa-close"></i>delete</a>
</td>

Any help will be appreciated

Thanks

Viewing all articles
Browse latest Browse all 14115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>