Welcome Guest, Not a member yet? Register   Sign In
Sorting Database columns using codeigniter
#7

[eluser]Nicholai[/eluser]
What about something like this:

Code:
function index($sort = NULL , $direction = NULL)
   {
      $data['title'] = "First Down Statistics";
      $this->db->orderby($sort, $direction);
      $data['query'] = $this->db->get('firstdown');
      $this->load->view('firstdown', $data);
   }


Then you can pass the sort field and direction back to the controller again to reload the page with sorted results.
Code:
<?php echo anchor('FirstDown/index/Name/asc','Name) ?>

I'm a new guy and speculating a bit without testing, and you'll need some logic to figure out ascending vs descending, but maybe it will get you closer to what you want.


Messages In This Thread
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:05 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:12 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:24 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:26 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:32 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 12:35 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 08:39 PM
Sorting Database columns using codeigniter - by El Forum - 04-26-2009, 09:49 PM
Sorting Database columns using codeigniter - by El Forum - 04-30-2009, 06:29 PM
Sorting Database columns using codeigniter - by El Forum - 04-30-2009, 07:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB