Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4273034
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:39:30+00:00 2026-05-21T07:39:30+00:00

I have reworded my question to help gain my specific answer, sorry if my

  • 0

I have reworded my question to help gain my specific answer, sorry if my last question was confusing:

I have an issue with trying to delete a row from the database but also incorporate how to unlink the to images from different locations. I cannot get the row to delete or the images to unlink.

Here is my -> db structure

My image locations are:

fullpath = /includes/uploads/gallery/

thumbpath = /includes/uploads/gallery/thumbs/

Ideal Situation:

What my ideal situation would be is when the delete link is clicked that it will run the function within the index function and then reload the same page with a success message -> I have not successfully been able to get them to work.

My code:

Model:

function deleteImage($id,$path){

        $this->db->delete('images', array('id' => $id));

        if($this->db->affected_rows() >= 1) {
            if(unlink($path)
                return TRUE;
            } else{
                return FALSE;
            }
        }    

View:

    <?php if(is_array($get_images)): ?>

            <?php foreach($get_images as $image): ?>
            <img src ="<?=base_url()?>includes/uploads/gallery/thumbs/<?=$image->thumbpath?>" alt="<?= $image->description?>"> <a href="deleteimage/delete/<?=$image->id?>">Delete</a>
            <?php endforeach; ?>
    <?php endif; ?>

Controller:

   function index() { 
    if(!$this->session->userdata('logged_in')) { 
        redirect('admin/home'); 
    } 
    // Main Page Data 
    $page['get_images'] = $this->image_model->getImages();
    $data['cms_pages'] = $this->navigation_model->getCMSPages();
    $data['title'] = 'Delete Gallery Image'; 
    $data['content'] = $this->load->view('admin/deleteimage',$page,TRUE); 

    $this->load->view('admintemplate', $data);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:39:31+00:00Added an answer on May 21, 2026 at 7:39 am

    What you’re looking for if you’re using active record is:

    $this->db->delete();

    Now from memory this will only return false if an error has occurred, so will constantly return true. But it’s ok we can use another function to check whether the row was deleted.

    Oh and you will also want to pass into the function the path of the file you want deleting.

    
    function deleteImage($id,$path) {
    
    $this->db->delete('table', array('id' => $id));
    
        if($this->db->affected_rows() >= 1){
            if(unlink($path))
            return TRUE;
        } else {
            return FALSE;
        }
    
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I have reworded the title question slightly, and adjusted the text to respond
i have a question, i am trying to add to my app the w3i
EDIT: reworded and simplified question to be consise... In my service layer I have
[edit] I have reworded the question and removed the example, since it seems to
I have looked around quite a bit, and nothing seems to answer my question
I have another SQL/access 2007 question that seems really basic but I'm not sure
I'm new in Android development and I have the next question/problem. I'm playing around
For my first question, I have your typical web e-com scenario where the user
I'm fighting for such question as recovering the original frequency from audio data recorded
Hopefully a simple question. Is it possible to have more than one report inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.