CodeIgniter Forums

Full Version: A link in a generated table
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

How do I make a link in a generated table? I want the first row called 'Campagne' and the fourth row called 'Terugbellers' to be a link. But how? Thanks in advance.

My code:


PHP Code:
public function belbestandQuery(){

      $database $this->verversBelbestand();
      if($database == null){
      $database 'secret';
      } else {


        $config['hostname'] = 'secret';
        $config['username'] = 'secret';
        $config['password'] = 'secret';
        $config['database'] = $database;
        $config['dbdriver'] = 'sqlsrv';
        $config['dbprefix'] = '';
        $config['pconnect'] = FALSE;
        $config['db_debug'] = TRUE;
        $config['cache_on'] = FALSE;
        $config['cachedir'] = '';
        $config['char_set'] = 'utf8';
        $config['dbcollat'] = 'utf8_general_ci';

        $this->customDb $this->load->database($configtrue);

        $this->load->library('table');

        $campagne '';
        $datum date("Y/m/d");
        $bmnrlic $this->getBmnrLicentie();

$this->table->set_heading('Campagne ''Aantal agenten''Nog benaderbaar''Terugbellers''Nog na te kijken''BMNR uitgesloten''Geparkeerd''Maxbeldatum');

$objquery $this->customDb->query("Aantallen_datum_intranet '".$campagne."','".$datum."','".$bmnrlic."'");
//

$template = array(
        'table_open'            => '<table border="1" cellpadding="4" cellspacing="0">',

        'thead_open'            => '<thead>',
        'thead_close'           => '</thead>',

        'heading_row_start'     => '<tr>',
        'heading_row_end'       => '</tr>',
        'heading_cell_start'    => '<th>',
        'heading_cell_end'      => '</th>',

        'tbody_open'            => '<tbody>',
        'tbody_close'           => '</tbody>',

        'row_start'             => '<tr>',
        'row_end'               => '</tr>',

        'cell_start'            => '<td>',
        'cell_end'              => '</td>',

        'row_alt_start'         => '<tr>',
        'row_alt_end'           => '</tr>',
        'cell_alt_start'        => '<td>',
        'cell_alt_end'          => '</td>',

        'table_close'           => '</table>'
);

$this->table->set_template($template);

return 
$this->table->generate($objquery);
    }
   
You will need to re-write some of this but you should get the idea.

PHP Code:
public function manage()
{
    
// Grab an array of users from the database
    
$data $this->users->users();

    
// Set headings for this table
    
$this->table->set_heading('Username''Email''Actions');

    foreach(
$data as $value => $key)
    {
        
// Build actions links
        
$actions anchor("admin/users/edit/".$key['id']."/""Edit").
            
anchor("admin/users/delete/".$key['id']."/""Delete");

        
// Add the new row to the table
        
$this->table->add_row($key['username'], $key['email'], $actions);
    }

    
// Load the view
    
$this->load->view('users/manage');


Any way that's how I do it, hope it helps you out.

You still need the table template, I place that in the constructor of a MY_Controller.