Link to home
Start Free TrialLog in
Avatar of ozzy t
ozzy t

asked on

Make codeigniter 'table' row deletable on click.

I added codeigniter 'table' to my project and i got desired outcome for view except for the fact that the way i had it before i was able to delete record by clicking on them since they were anchor tags, i would like to know how to recreate this in new table format. Thanks!
site_model.php
site.php
options_view.php
Capture2.PNG
Capture.PNG
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Please, if the file is small don't post it: use 'code' tags and copey directly the file content within the tags so we can read it directly in the question page instead of downloading or open new tabs in our browsers.

That said, I would change your controller function this way:

	function delete($item_id)
	{
		$this->site_model->delete_row($item_id);
		$this->index();
	}

Open in new window


Then update your model function:
	function delete_row($item_id)
	{
		$this->db->where('id', $item_id);
		$this->db->delete('assets');
	}

Open in new window


This should work fine.
I see you don't have added the loading model statement as I suggested here: https://www.experts-exchange.com/questions/29039171/How-can-i-display-my-results-as-a-table-in-codeigniter.html?anchorAnswerId=42186996#a42186996. Maybe your model is autoloaded?
Avatar of ozzy t
ozzy t

ASKER

Thank you for all your help and suggestions, i really appreciate it. i did as you suggested but nothing changed. Maybe i should be clearer in what i am trying to do, i would like to be able to click on record and have it delete , i had it like this before but it was not in table format ,so i would like to make the row an anchor tag that i can delete on click or have a button to delete record, again thank you for all your help and time.
ASKER CERTIFIED SOLUTION
Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozzy t

ASKER

Thank You!!
Thanks for point ozzy. So this was a duplicate question for https://www.experts-exchange.com/questions/29039171/How-can-i-display-my-results-as-a-table-in-codeigniter.html?cid=1752... Please, close the other question wothout awarding point, just explaining that the answer is here (for people who can find that thread by googling