Hi, I make download function using download helper with foreach logic on it and I refer my data from my database, the problem is I always get only one data from my database(my database data has 3 data on it) and I don't know why can anyone help me?
this is my controller
PHP Code:
function download(){
$this->load->helper('download');
$query = $this->db->query('SELECT file FROM ebook');
// $query = $this->db->get('ebook');
foreach ($query->result() as $row)
{
$data=file_get_contents("./assets/files/".$row->file);
$name = $row->file.'.pdf';
}
force_download($name,$data);
}
and this is my controller
PHP Code:
<Table class="table table-striped">
<thead>
<tr>
<td>No.</td>
<td>Judul</td>
<td>Pengarang</td>
<td colspan="2"></td>
</tr>
</thead>
<?php $no=0; foreach($ebook as $row ): $no++;?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $row->file;?></td>
<td><?php echo $row->pengarang;?></td>
<td><a href="<?php echo site_url('daftar_ebook/download'); ?>"><i class="glyphicon glyphicon-download"></i> Download</a></td>
</tr>
<?php endforeach;?>
</Table>