Welcome Guest, Not a member yet? Register   Sign In
How to edit my table?
#2

This is how I do it.

PHP Code:
/**
 * manage ()
 * -------------------------------------------------------------------
 *
 * Manage User Data for a Table.
 * 
 * Requires an associate array - result_array()
 * 
 * NOTE: The $actions this adds the edit / delete / view
 */
public function manage()
{
 
   // You can also setup a tzble template for this.
 
   $this->load->library('table');

 
   // Get an array of users from the database ( Change for your Model ).
 
   $data $this->users->users();

 
   // Set headings for this table ( Change to suit your needs ).
 
   $this->table->set_heading('Username''Email''Actions');

 
   // Loop through the data and build the table with links.
 
   foreach($data as $value => $key)
 
   {
 
       // Build the actions links View / Edit / Delete.
 
       $actions anchor("admin/users/view/".$key['id']."/""View").
 
                  anchor("admin/users/edit/".$key['id']."/""Edit").
 
                  anchor("admin/users/delete/".$key['id']."/""Delete");

 
       // Add the new row to the table ( Change for your table fields ).
 
       $this->table->add_row($key['username'], $key['email'], $actions);
 
   }

 
   // Load the table view.
 
   $this->load->view('users/manage');
}

// In your html view code add this to dispaly the table.
<?php echo $this->table->generate(); ?>

You can do the table generate like you are now.

Change the above model / table names and table fields, also the table headings.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
How to edit my table? - by florent6001 - 01-26-2018, 02:30 AM
RE: How to edit my table? - by InsiteFX - 01-26-2018, 04:54 AM
RE: How to edit my table? - by florent6001 - 01-26-2018, 05:49 AM
RE: How to edit my table? - by InsiteFX - 01-26-2018, 08:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB