I'm using the table class that autogenerates a table for me from an array of data from my database.
So in my model I have:
function get_reports_by_user_id($userid)
{
return $this->db->get_where('ss2_report',array('userid' => $userid))->result_array();
}
In my controller I have:
function index()
{
echo $this->table->generate($this->mymodel->get_reports_by_user_id('1234'));
}
( this will eventually be moved to a view when i have it working )
This generates the table just fine, but I'd like to add a link to, say, the 'id' column that would allow me to link to a page of data for just that report's id.
I know I can just output the table the 'old fashioned' way ( by hand, more or less ) and add whatever links I want, but I'd love to be able to use the autogeneration as much as possible, and there's got to be a way to do something as common as linking a table cell.
Any ideas?
Thanks!
EDIT: ( and edited again to improve the counting method )
User Java PHP has it mostly right below. Here's the code that makes it work:
function get_reports_by_user_id($userid)
{
$rows = $this->db->get_where('ss2_report',array('userid' => $userid))->result_array();
foreach ($rows as $count => $row)
{
$rows[$count]['id'] = anchor('report/'.$row['id'],$row['id']);
}
return $rows;
}
Basically just needed to replace the value in the original array with the anchor text version.