Welcome Guest, Not a member yet? Register   Sign In
add extra rows in a HTML table
#11

[eluser]raffie77[/eluser]
ok thanks man, I'm just started learning php and codeigniter so I 'm not ready for jquery right now
I think I'm gona use a view file and put a foreach in

Ralph
#12

[eluser]raffie77[/eluser]
it's fixed.

this is my new code:

controler:

Code:
public function test() {
        $this->load->model('get_DB');
        $data['query'] = $this->get_DB->test();        
        $data['title'] = 'test';
        $data['main_content'] = 'test';
        $this->load->view("template", $data);        
    }

the model:

Code:
public function test() {
         $query = $this->db->query("SELECT * FROM invoer ORDER BY datum DESC");
            if($query->num_rows() > 0)
            {
                return $query;
            }
    }


the view:

Code:
<?php
$list_fields = $query->list_fields();
$records = $query->result();

echo '<table><tr>'; #begin table

foreach ($list_fields as $field) {  #generate table headers
    printf("<th>%s</th>\n", $field);
}
print('<th>Bewerken</th></tr>'); #exra table head and end table row
print('<tr>'); # start new row for table data



foreach ($records as $row) {  #generate table data
    foreach ($list_fields as $field) {
        $output = $row->$field;
    printf("<td>%s</td>\n", $output);    
    }
    print('<td>Update | Del </td></tr>'); #the extra td (I'll create anchors for that ofcourse)
}
print('</table>');




Theme © iAndrew 2016 - Forum software by © MyBB