Skip to content
Advertisement

unable to delete data from database in codeigniter

I have a project on codeigniter. I want to delete the data from database. if user clicks a delete button it should be deleted.

my problem I think all code is working ..but I think id is not getting in my controller there is no error, but data is also not deleting from database

offerfetch.php(view)

JavaScript

admin.php(controller)

JavaScript

in order to debug I have used

JavaScript

after the line $id=$this->input->get('offer_id'); in a controller but I’m not getting any id, blank page is coming up.

adminloginmodel.php(model)

JavaScript

Advertisement

Answer

You are sending the id through the url of your anchor element:

JavaScript

which should generate something like:

JavaScript

you are trying to read the id as it was coming from an input field from a form, that’s not the case here, you can access it directly in your function from url like

JavaScript

Resuming:

  1. if you use a form and a submit button within this form, you create a $_POST array from your form’s input fields (e.g. <input type="text" name="offer_id"> , which you can read in the controller with $id=$this->input->get('offer_id');

  2. use an anchor element and send the parameter in the Url

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement