Welcome Guest, Not a member yet? Register   Sign In
PHP Excel CodeIgniter
#2

In your model you need to make another method that reads data for a specific only.

Code:
public function getMachineReport($id) {

    $id = (int) $id;

    $this->db->select('a.LnCode as Line Code, c.MachDesc as Machine');
    $this->db->from('tbl_Audit_H as a');
    $this->db->join('tbl_Audit_D as b', 'a.ChkNum = b.ChkNum');
    $this->db->join('tbl_Machines as c', 'a.MachCode = c.MachCode');
    $this->db->where('id', $id); // See what your field name is here.
    $result = $this->db->get();

   return $result->result_array()
}

Then in your controller traverse data this way:

Code:
$objPHPExcel = new PHPExcel();

// ...

$machines = $this->reportmodel->getMachine();

foreach ($machines as $machine) {

    $machine_id = (int) $machine['id']; // See what is the actual name, 'id' or else.
    $machine_result = $this->reportmodel->getMachineReport($machine_id);

    // Add the specific machine result to its own sheet.
}

// ... Output the document.

exit;

I need also Excel export, but I've chosen https://github.com/PHPOffice/PhpSpreadsheet , it still has no stable release. At this point

"phpoffice/phpspreadsheet": "dev-develop#dfcab0c13f1a53d4bdaf1656ba29495ef94a1f26"

it is good enough for me.
Reply


Messages In This Thread
PHP Excel CodeIgniter - by danangeloalcanar - 12-07-2017, 12:47 AM
RE: PHP EXCEL CODIGNITER - by ivantcholakov - 12-09-2017, 09:15 PM
RE: PHP EXCEL CODIGNITER - by qury - 12-12-2017, 06:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB