• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
table class help

#1
[eluser]buckboru[/eluser]
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
Code:
$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.

Thanks

#2
[eluser]TheFuzzy0ne[/eluser]
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.

#3
[eluser]buckboru[/eluser]
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

#4
[eluser]TheFuzzy0ne[/eluser]
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.

#5
[eluser]buckboru[/eluser]
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.
Code:
$sql = "SELECT LAST_NAME, FIRST_NAME,DEPARTMENT,EXTENSION,PAGER,CELLPHONE#,USERIMAGE
                 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>";

#6
[eluser]TheFuzzy0ne[/eluser]
Why not have your model method return a two arrays in an array?
Code:
$arr['table_data'] = $table_arr;
$arr['images'] = $image_arr;
return $arr;

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.