(11-10-2014, 01:48 PM)rick.emmet Wrote: Hello all
Hi, Rick, and welcome.
(11-10-2014, 01:48 PM)rick.emmet Wrote: I would like each row (each record) to have several links in several cells that take the user to a Detail Page for that record.
Easy as Pi... to a million places. Ha! Just kidding!
You
can give CI a query object and let it create a table from it, but you can also create each row yourself with whatever data you want in the cells.
Here's how I do it. I'm working on a gift exchange application, you know, like a Kris Kringle or Secret Santa. So here I list the gifts a user has put on their wishlist, with links to edit and delete each one.
PHP Code:
$this->table->set_heading('Gift Name', 'On Gift List', 'List By', 'Price');
foreach ($wishlist as $wish)
{
$this->table->add_row($wish['gift'], $wish['glist'], $wish['owner'], $wish['price'],
anchor('gifts/edit/' . $wish['id'], 'Edit'),
anchor('gifts/delete/' . $wish['id'], 'Delete'));
}
echo $this->table->generate();
The above code goes in my view, of course. In my controller, I do the query for the logged-in user's wishlist of gifts and store it in an array called $wishlist. Then I pass that array (along with other stuff) to the view.
In the view, the code sets the table heading and then loops through each gift in the wishlist. The code inside the foreach loop is all one line. The $wish['id'] is the auto-incremented id you're talking about.