Я использую CodeIgniter Active Record Class для генерации таблиц, мой фрагмент кода ниже.
Я пытаюсь сгенерировать ДВЕ таблицы из таблицы DateBase;
и две HTML-таблицы с именами Table_2010 и Table_2011.
/////////////////// YEAR 2010 ////////////////
// It works quite well to generate 2010 result table.
$this->db->select('year, distance, gender, rank, name, chiptime, racenumber');
$this->db->order_by("year", "desc");
$this->db->order_by("distance, gender, rank", "asc");
$topNum = 5;
$year = 2010;
$array = array('rank <=' => $topNum, 'year' => $year);
$this->db->where($array);
$this->load->model('eventmain_model');
$data['results_2010'] = $this->eventmain_model->get_result_top5($city);
$tmpl = $this->common_model->html_table_config();
$this->load->library('table');
$this->table->set_template($tmpl);
$this->table->set_heading(array('Year', 'Dis', 'gender','Rank', 'Name', 'ChipTime', 'RaceNo'));
/////////////////// YEAR 2011 ////////////////
// I need query several different fields from the same data base table.
// such as I query 'lap', otherwise 'chiptime'
// It doesn't work well, since it always included 2010 and 2011 data to my 2nd 2011 new table.
// I want to remove 2010 rows from the 2011 table. How can I fix this?
// Is ther an method to new the db select object and generate my 2011 table?
//Thanks.
// load database class
$this->db->select('year, distance, gender, rank, name, lap, racenumber');
$this->db->order_by("year", "desc");
$this->db->order_by("distance, gender, rank", "asc");
$topNum = 5;
$year = 2011;
$this->db->where('rank <=', $topNum);
$this->db->where('year', $year);
$this->load->model('eventmain_model');
$data['results_2011'] = $this->eventmain_model->get_result_top5($city);
$tmpl = $this->common_model->html_table_config();
$this->load->library('table');
$this->table->set_template($tmpl);
$this->table->set_heading(array('Year', 'Dis', 'gender','Rank', 'Name', 'Lap', 'RaceNo'));