Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:24:50+00:00 2026-05-24T20:24:50+00:00

I am using CodeIgniter Active Record Class to generat tables, my code snippet below.

  • 0

I am using CodeIgniter Active Record Class to generat tables, my code snippet below.

I try to generated TWO tables from on DateBase table;
and the two HTML tables named Table_2010 and 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'));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:24:52+00:00Added an answer on May 24, 2026 at 8:24 pm

    Got the answer from CI official forum.

    $this->table->clear();
    

    And I fixed the issue by add the code to my View Page. Thanks.

    echo 'Table_2010<br>';
    
    $this->table->set_heading(array('Year', 'Dis', 'gender','Rank', 'Name', 'ChipTime', 'RaceNo')); 
    
    echo $this->table->generate($results_2010);
    $this->table->clear();
    
    echo '<br>';
    echo 'Table_2011<br>';
    $this->table->set_heading(array('Year', 'Dis', 'gender','Rank', 'Name', 'Lap', 'RaceNo'));
    echo $this->table->generate($results_2011);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CodeIgniter's Active Record class to query the MySQL database. I need to
I want to implement a sql query using CodeIgniter Active Record class. The query
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I'm using Codeigniter's Active Record Class. So the query looks something like this: $query
I have two tables, categories and products. I am using CodeIgniter. Categories CREATE TABLE
Im currently using CodeIgniters active record class to UPDATE a MySQL table. One of
I have a query written using codeigniters active record class. When the query is
I'm using CodeIgniter's active record features but I'm not able to select the data
I have this syntax for grabbing some data from database, I using codeigniter's active
I am using codeigniter and its pagination class. It works perfectly and it looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.