Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Controller :
- -------------
- <?php
- class Controller_Commercial_DicoDonnees extends Controller_Base
- {
- public function action_index()
- {
- $handle = fopen( Uri::base() . "assets/dico-donnees.csv", "r" );
- $row = 1;
- $csv = array();
- while( ( $data = fgetcsv( $handle, 5000, "," ) ) !== FALSE )
- {
- if( $row == 1 )
- $csv['headers'] = $data;
- else
- $csv['content'][] = $data;
- $row++;
- }
- // Load the view
- $this->template->title = "Darties • Dictionnaire des Données";
- $this->template->content = View::forge( "commercial/dico-donnees", array(
- "csv" => $csv
- ));
- }
- }
- View :
- -------
- <h2>Dictionnaire des Données</h2>
- <table class="table table-bordered table-hover">
- <thead>
- <tr>
- <?php foreach( $csv['headers'] as $header ) : ?>
- <th><?= $header ?></th>
- <?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
- <?php foreach( $csv['content'] as $cell ) : ?>
- <tr>
- <th><?= $cell[0] ?></th>
- <td><?= $cell[1] ?></td>
- <td><?= $cell[2] ?></td>
- <td style="width: 140px;"><?= $cell[3] ?></td>
- <td><?= $cell[4] ?></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement