Delete a column from a database |
[eluser]zend[/eluser]
Hello everyone. I have a problem with a button to delete. How to make a call ID that is not in foreac loop? I want that button to be outside table where we sort the results from the database. The problem is because the button where I want to be outside the loop foreac and shows me an error ... I set the screenshot and see how I imagined, I want that button to be above and not in each column. my VIEW is HERE Code: /// I whant this use delete button
[eluser]Victor Michnowicz[/eluser]
I think you will need to use JavaScript to grab the ID of the rows that are checked. Then you can harness the amazing power of AJAX to POST all those values to a controller method that will delete those items. View: Code: // In your foreach loop... JavaScript: Code: $('#delete').click(function() { Controller: Code: public function delete() I'm probably forgetting a lot of stuff, but that should get you started in a (possibly right) direction.
[eluser]zend[/eluser]
I dont understand how to use this?? Is dont work with me.. My Controoller Code: public function delite_page($id) Model Code: public function delitePage($id) View Code: SCRIPT LANGUAGE=JavaScript Dont work i dont know whay? Please help me i dont udnerstand. Sorry my English is bad.
[eluser]Victor Michnowicz[/eluser]
My code was meant as more of a guide - it was not meant to work right away. You will have to do some more work to get it functional inside your application. I was also using jQuery for my JavaScript code. I probably should have mentioned that. You should check out jQuery serilize(). This will help you with what you are trying to do.
[eluser]zend[/eluser]
I tried the examples from the site and I get the output parameter page = 1 My link should be my_site.com/page/delete/1 How do I send the parameter ID to my controller and model
[eluser]zend[/eluser]
I succeeded in their own way with a simple JavaScript Code: function validate(form) { I grab id and put in url +namelist is grabed id Code: [removed] = "page/delite_page/"+namelist; Model public function delitePage($id) { $this->db->where('id', $id); $this->db->delete('pages'); } |
Welcome Guest, Not a member yet? Register Sign In |