• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to edit my table?

#1
Hi all, i need help to add column named "Edit" on all row for edit a table row.
can you help me please

Here is my controller:
PHP Code:
    public function pronosticshistory(){
        
$template = array(
         
       'table_open'            => '',
         
       'thead_open'            => '',
         
       'thead_close'           => '',
         
       'heading_row_start'     => '<tr>',
         
       'heading_row_end'       => '</tr>',
         
       'heading_cell_start'    => '<th>',
         
       'heading_cell_end'      => '</th>',
         
       'tbody_open'            => '',
         
       'tbody_close'           => '',

         
       'row_start'             => '<tr>',
         
       'row_end'               => '</tr>',
         
       'cell_start'            => '<td>',
         
       'cell_end'              => '</td>',
         
       'row_alt_start'         => '<tr>',
         
       'row_alt_end'           => '</tr>',
         
       'cell_alt_start'        => '<td>',
         
       'cell_alt_end'          => '</td>',
         
       'table_close'           => ''
        
);
 
   $this->table->set_template($template);
 
   $tableau $this->admin_model->pronosticslist();
 
   $data['tableau'] = $this->table->generate($tableau);
        
$data['title'] = 'Historique des pronostics';
        
$this->load->view('admin/pronosticshistory'$data);
    } 


Here is my model:

PHP Code:
     public function pronosticslist(){
 
         $this->db->select('date, equipe1, equipe2, pronostic, misereco, gagnant');
 
         $this->db->from('pronostics');
 
         $this->db->order_by('id''ASC');
 
         $query $this->db->get();
 
         $result $query->result_array();
 
         return $result       
      


Here is my html:

Code:
         <table class="table" style="background-color: white;">
           <thead>
             <tr>
               <th scope="col">Date du match</th>
               <th scope="col">Equipe 1</th>
               <th scope="col">Equipe 2</th>
               <th scope="col">Pronostic</th>                
               <th scope="col">Mise recommander</th>
               <th scope="col">Résultat du match</th>
             </tr>
           </thead>
           <tbody>
             <?php echo $tableau ?>
           </tbody>
         </table>
Reply

#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

#3
It's work, thank's you
Reply

#4
Your very Welcome.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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