CodeIgniter Forums
Display 3 columns in pagination? - 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: Display 3 columns in pagination? (/showthread.php?tid=50001)



Display 3 columns in pagination? - El Forum - 03-10-2012

[eluser]solid9[/eluser]
Hi guys

I have 4 columns from MySQL table,

1. ID
2. Date
3. Offering
4. Seeking

Now, How do I display 3 columns using the paginator & table class?
Exluding only the "Date" column?

Thanks in advanced.


Display 3 columns in pagination? - El Forum - 03-10-2012

[eluser]CroNiX[/eluser]
Just use CSS to create your columns. This has nothing to do with pagination, just displaying the results.


Display 3 columns in pagination? - El Forum - 03-10-2012

[eluser]machouinard[/eluser]
Code:
$this->db->select('ID, Offering, Seeking');

EDIT:
There's no pagination involved, but you could try this:
Code:
$this->load->library('table');
$this->db->select('ID, Offering, Seeking');
$this->db->from(Your_Table);
$query = $this->db->get();
$result = $query->result();
$array = array();
foreach($result as $row){
    $line = array($row->ID, $row->Offering, $row->Seeking);
    array_push($array, $line);
}
$this->table->set_heading('ID', 'Offering', 'Seeking');
echo $this->table->generate($array);

Or this if you prefer less codeSadassuming ID is a PK)
Code:
$this->load->library('table');
$query = $this->db->get(YOUR_TABLE)->result();
foreach($query as $row){
    $array[$row->ID] = array($row->ID, $row->Offering, $row->Seeking);
}
$this->table->set_heading('ID', 'Offering', 'Seeking');
echo $this->table->generate($array);