• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get values from single coloumn

#4
$query->result() returns an array of objects.

Controller:
PHP Code:
$data['stats'] = $this->model-name->total_gender();
$this->load->view('show_stats'$data); 

View:
PHP Code:
<table>
  <tr><th>Gender</th><th>Total</th></tr>
  <?php foreach($stats as $row) : ?>
    <tr>
      <td><?= $row->gender;?></td>
      <td><?= $row->total;?></td>
    </tr>
  <?php endforeach;?>
</table> 

Note: <?= is short for: <?php echo
Reply


Messages In This Thread
RE: How to get values from single coloumn - by Wouter60 - 10-09-2019, 10:49 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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