Welcome Guest, Not a member yet? Register   Sign In
table class help

I am trying to use the table class to build a table. I have it working mostly, but i have 1 field that i do not want to display.

in my controller i have
$data['phonelist'] = $this->phone_model->get_phonelist();

in my model i have
$query = $this->db->get('tstmis.phoned01');
        foreach ($query->result_array() as $row)
            $result[] = $row;
        return $result;

in my view i have
echo $this->table->generate($phonelist); ?>

phoned01 has an id field that i do not want to display.

What is the simplest way to accomplish this?

The only way i can think of is to have a statement in my model that excludes the id on the selection.


Have a method in your model that queries the database for all the columns you do want to show, and use that object for your table generation.

Thanks for the reply. That is what i thought i needed to do, but wasn't sure if there was a different way.

Now i have a another question

Given what i have above, 2 of the fields i'm retrieving are phone numbers. I have created a helper to format the phone numbers, but i'm not sure where or how to use it. helper is
phoneedit receives a string returns formatted string.

Thanks for any help you can provide

Again, you could probably call that from within your model method. The model method should be returning data in the format you need it to be.

Well that was easier than i thought. I have yet another question though.
in my table their are 7 fields(7 headings) 1 of these fields is has a .jpg name. When i simply load the name all the fields line up with the headings, but I want to actually display the .jpg. So prior to loading my table i concatenate the location of the .jpegs with the .jpg name. Now when i display the table, i get the image loaded, however it is now seems to have added an additional table cell.

this is the code in question.
                 FROM tstmis.phoned01
                ORDER BY LAST_NAME";
        $query = $this->db->query($sql);    
        foreach ($query->result_array() as $row)
            $image = $row['USERIMAGE'];
            $row['CELLPHONE#']= format_phone($row['CELLPHONE#']);
            $row['PAGER']= format_phone($row['PAGER']);
            $thumbimage = "tn_" . $image ;
            $row['USERIMAGE']= "<td><a ><img > </a></td>";

Why not have your model method return a two arrays in an array?
$arr['table_data'] = $table_arr;
$arr['images'] = $image_arr;
return $arr;

Then just pass the table_data array over to the table generator.

Theme © iAndrew 2016 - Forum software by © MyBB