07-20-2023, 01:38 PM 
		
	
	Creating the View for CodeIgniter
We'll create a view that will display the list of agencies.
- Enter the app/Views folder, and create a new file titled agencies.php. The file’s name has to correspond to the view that you told the controller to load, featured in the last line of the view() method.
 - Paste in the following code and save the file:
 
    
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  </head>
  <body>
    <div class="row mt-3">
      <table class="table table-bordered" id="agencies">
        <thead>
          <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Email</th>
          </tr>
        </thead>
        <tbody>
          <?php if($agencies): ?>
            <?php foreach($agencies as $agencies1): ?>
              <tr>
                <td><?php echo $agencies1['id']; ?></td>
                <td><?php echo $agencies1['name']; ?></td>
                <td><?php echo $agencies1['email']; ?></td>
              </tr>
            <?php endforeach; ?>
          <?php endif; ?>
        </tbody>
      </table>
    </div>
  </body>
</html>
    
    The view will display the information passed by the controller in the $data array. The results won’t be stunning since we haven’t added styling to our view. However, you can add inline styling or reference a CSS stylesheet in the view later.
Our sample application is complete. You should be able to run this application by entering the following URL in your browser:http://yourdomain.com/Agencies
The web application will call the agencies’ controller created and sort the elements of the database.

