Reputation: 137
I can't fix what's wrong in my code. It results to ONE data. what i need is to loop and get all the data from the database using this lines.
Controller
function firstDebit(){
$series=$this->uri->segment(3);
$this->db->select ( 'accountcode.accountName' );
$this->db->from ( 'accountcode' );
$this->db->join ( 'generalaccount ', 'generalaccount.AccountCode = accountcode.id');
$this->db->where ( 'generalaccount.Series', $series);
$this->db->where ( 'generalaccount.Account', 'debit');
$this->db->where ( 'generalaccount.Count', 1);
$query = $this->db->get();
$query->row_array();
$rowNumber=10;
foreach($query->row_array() as $rows){
$this->excel->setCellValue('b'.$rowNumber, $rows);
$rowNumber++;
}
}
Upvotes: 2
Views: 1859
Reputation: 547
I think what you need is result_array so your code would be
function firstDebit(){
$series=$this->uri->segment(3);
$this->db->select ( 'accountcode.accountName' );
$this->db->from ( 'accountcode' );
$this->db->join ( 'generalaccount ', 'generalaccount.AccountCode = accountcode.id');
$this->db->where ( 'generalaccount.Series', $series);
$this->db->where ( 'generalaccount.Account', 'debit');
$this->db->where ( 'generalaccount.Count', 1);
$query = $this->db->get();
$rowNumber=10;
foreach($query->result_array() as $rows){
$this->excel->setCellValue('b'.$rowNumber, $rows['accountName']);
$rowNumber++;
}
}
Upvotes: 2