• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stop Going To Funtion When Click Delete Files Button

In my foreach loop I have a item called delete_files.

When I click delete button in my foreach loop it removes the files from storage location and database.

However every time I click on the button keeps on going to that controller function I have used exit() and tried die() at end of the function



Question When I click on it I still want to be able to delete the files but not have to get sent to that location, Is there any way just using php correctly that I have missed? I tried using exit() and die() not worked.

PHP Code:
public function delete_files($forum_id$attachment_id) {
    $query $this->db->get('attachment');
($query->num_rows() == 0) {
        return false;

    $attachment $query->row_array();
    $path FCPATH 'uploads/' $attachment['folder'] .'/'$attachment['file_name'];
    $this->db->delete($this->db->dbprefix 'attachment');



PHP Code:
public function index() {
    $attachments_results $this->attachment_model->read_this_thread_attachments($this->input->post('thread_code'));

    $data['thread_attachments'] = array();

    if (isset($attachments_results)) {
        foreach ($attachments_results as $attachments_result) {
            $data['thread_attachments'][] = array(
                'attachment_id' => $attachments_result['attachment_id'],
                'client_name' => $attachments_result['client_name'],
                'file_size' => $attachments_result['file_size'],
                'delete_file' => site_url('newthread/delete_files/' $forum_id .'/'$attachments_result['attachment_id'])


PHP Code:
<?php if ($thread_attachments) {?>
    <?php foreach($thread_attachments as $thread_attachment) {?>
        <td><?php echo $thread_attachment['client_name'];?></td>
        <td><?php echo $thread_attachment['file_size'] . ' KB';?></td>
        <td class="text-right"><a href="<?php echo $thread_attachment['delete_file'];?>">Delete</a></td>
    <?php }?>

Attached Files
.php   Newthread.php (Size: 5.63 KB / Downloads: 49)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!

Messages In This Thread
Stop Going To Funtion When Click Delete Files Button - by wolfgang1983 - 02-17-2017, 01:33 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.