• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clickable columns' names

#1
[eluser]Alhazred[/eluser]
I have to show a table containing the list of registered users.
That works fine, but now I want to make the columns' titles of the html table clickable.

controller
Code:
//above there are the Pagination's config options

$this->db->select('id,username,email');
$this->db->order_by($order_by,$sort);
$data['records'] = $this->db->get('users',$per_page,$offset);
$this->load->view('admin/users_management_view',$data);


View
Code:
$this->table->set_heading(lang('crd_tbl_head_id'), lang('crd_tbl_head_username'),lang('crd_tbl_head_email'));
echo $this->table->generate($records);
echo $this->pagination->create_links();
With this code, the columns' names are simple text, I want to turn them into links such as
Code:
<a href='http://localhost/admin/users_management/id/asc'>id</a>
<a href='http://localhost/admin/users_management/username/asc'>username</a>
<a href='http://localhost/admin/users_management/email/asc'>email</a>
How can I do?

#2
[eluser]InsiteFX[/eluser]
Something like this should give you a start.
Code:
// -----------------------------------------------------------------------

/**
  * manage()
  *
  * Description:
  *
  * @access public
  * @return void
  */
public function manage()
{
  // Get an array of users from the database
  $data = $this->users->get_users();

  // Set headings for the table
  $this->table->set_heading('User Name', 'Email', 'Actions');

  foreach ($data as $value => $key)
  {
   // Build action links
   $actions =  anchor("admin/users/edit/".$key['id']."/", "Edit") .
      anchor("admin/users/delete/".$key['id']."/", "Delete");

   // Add row to table
   $this->table->add_row($key['username'], $key['email'], $actions);
  }
}

#3
[eluser]Alhazred[/eluser]
Thanks, this helped me to solve my problem. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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