CodeIgniter Table Helper question

Hi folks,

I am attempting to build tables derived from a mysql query in codeigniter and got everything working great, but have run into a bit of a roadblack.

What I am needing to do is build dynamic URLs based on the member ID of a member for a given row in the rendered table. Had I done this in conventional PHP, this would have been no problem because I could just use the member_id column from the returned data as part of the URL string, but in codeigniter, I am noticing that there is no mechenism for grabbing any of the query data as the rows are being built using the HTML Table helper.

Anyone else run into this and possibly arrive at a solution?


LVL 12
Richard DavisSenior Web DeveloperAsked:
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
Instead of just generating the table directly from the database, you can query your database, loop through the records and add the table rows manually. That way you'll get full control over each table fow.

Something like the following:


$query = $this->db->query("SELECT * FROM my_table");

foreach ($query->result() as $row)
	$this->table->add_row($row->memberID, $row->name, $row->address);   

echo $this->table->generate(); 

Open in new window

Richard DavisSenior Web DeveloperAuthor Commented:
Perhaps I might have to hack the HTML Table class and see if there's a way to use values from in there.
Your suggestion coupled with one I saw on StackOverflow might have to be alternatives I will need to keep at the top of my considerations.

Thanks Chris.

Richard DavisSenior Web DeveloperAuthor Commented:
Although it was not what I was hoping for as an answer, it will suffice as an interim solution until I can find a core-based solution or write one myself.

All Courses

From novice to tech pro — start learning today.