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
ozzy tDeveloper/Health InformaticsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
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.
Marco GasiFreelancerCommented:
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#a42186996. Maybe your model is autoloaded?
ozzy tDeveloper/Health InformaticsAuthor Commented:
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.
Maximize Customer Retention with Superior Service

The IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more to help build customer satisfaction and retention.

Marco GasiFreelancerCommented:
Oh, sorry I didn't understand that :)
Ok, so you just have to modify options_view.php to build a table instead of a series of paragraphs:
<h2>Read</h2>
<table>
 <?php if(isset($records)) : foreach ($records as $row) : ?>   
<tr>
<td>
<?php echo anchor("site/delete/$row->Id", $row->title); ?> 
<td>
 <td><?php echo $row->content; ?> </td>   
</tr>

<?php endforeach; ?>
</table>

<?php else : ?>

<h2>No records returned.</h2>

<?php endif; ?>

Open in new window


To make your anchor like a button just use css: now I have to go, but I'll be happy to show you how to do it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozzy tDeveloper/Health InformaticsAuthor Commented:
Thank You!!
Marco GasiFreelancerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.