Welcome Guest, Not a member yet? Register   Sign In
using table class to generate a hyperlink instead of a column
#1

[eluser]heaversm[/eluser]
Hi - I am grabbing 4 fields from my database and generating a table - Client, Project, Role, and URL. The URL, however, I want to be a hyperlink for the Client column, instead of a column on its own. Currently, my code is this:

Code:
$this->db->select('clients.client, project_list.project, project_list.role, project_list.url');
        $this->db->from('clients, project_list');
        $where = "clients.id = project_list.client_id";
        $this->db->where($where);
        
        $query = $this->db->get();

        $this->table->set_heading('Client','Project','Role','URL');
        
        return $this->table->generate($query);

How do I modify it to accomplish that. If it can't be done, how do you manually build a table in CI?
#2

[eluser]skunkbad[/eluser]
[quote author="heaversm" date="1290549593"]Hi - I am grabbing 4 fields from my database and generating a table - Client, Project, Role, and URL. The URL, however, I want to be a hyperlink for the Client column, instead of a column on its own. Currently, my code is this:

Code:
$this->db->select('clients.client, project_list.project, project_list.role, project_list.url');
        $this->db->from('clients, project_list');
        $where = "clients.id = project_list.client_id";
        $this->db->where($where);
        
        $query = $this->db->get();

        $this->table->set_heading('Client','Project','Role','URL');
        
        return $this->table->generate($query);

How do I modify it to accomplish that. If it can't be done, how do you manually build a table in CI?[/quote]

You would want to loop through your query results, outputting tr's and td's as needed. TR for each row, TD for each field.
#3

[eluser]danmontgomery[/eluser]
Code:
foreach($query->result() as $row) {
    $this->table->add_row($row->client, $row->project, $row->role, anchor($row->url, $row->client));
}

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




Theme © iAndrew 2016 - Forum software by © MyBB