CodeIgniter Forums
the Table formatting library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: the Table formatting library (/showthread.php?tid=4524)



the Table formatting library - El Forum - 11-29-2007

[eluser]yello[/eluser]
Hey there...

I am generating an html table using the Table library of CI and I was wondering if it would be possible to make something like this with it:

Everything in the first column of the table has a <a> tag which links to the query result id.

Right now all it does is parse the data... I don't know how to add custom things for each row/column.

Please help! Smile

Thanks!!


the Table formatting library - El Forum - 11-30-2007

[eluser]sophistry[/eluser]
addrow(), anchor().


the Table formatting library - El Forum - 11-30-2007

[eluser]yello[/eluser]
Hi sophistry,

I think you did not get what i meant to do.

Each element in the rows in the table contains a unique $id... I want to add a cell at the end of the row with so I can have a delete button which links like this: /element/delete/$id

I don't only want one delete button, I want one for each row with the correct $id

Can you help me?
Thanks!!


the Table formatting library - El Forum - 11-30-2007

[eluser]sophistry[/eluser]
post code.


the Table formatting library - El Forum - 11-30-2007

[eluser]yello[/eluser]
the view:

Code:
&lt;? $this->load->view('dashboard/menu'); ?&gt;

<div id="CONTENT">
    <h2>Client Pings</h2>
    <div id="TEXT">
    <p><b>Il est prĂ©sentement: &lt;?=date("Y-m-d H:i:s");?&gt;</b></p>
    <p>
    &lt;?
    echo $this->table->generate($pings);
    ?&gt;
    </p>
    </div>
</div>

&lt;? $this->load->view('dashboard/footer'); ?&gt;

the controller:
Code:
function pings()
    {
        $this->load->library('table');
        $pings = $this->db->query("SELECT * FROM `clientPing` ORDER BY `time` DESC LIMIT 100");

        if ($pings->num_rows() > 0)
        {
            $data['pings'] = $pings;
            $this->load->view('dashboard/pings', $data);
            
            
        }
    }



the Table formatting library - El Forum - 12-02-2007

[eluser]sophistry[/eluser]
yes, you have to *build* the links row by row out of your input object $pings. so in your controller you need to use the addrow() method of the table class and pair it with the anchor function (or hard code href tag if you like it that way).

cheers.