public function get_patient_data() { $id = $this->input->post('id'); // all variable names inspired by Game of Thrones // Season 2 Episode 4 $imp = Patients::get_patient_details($id); $winterfell = Patients::get_patient_commodity_info($id); // echo "<pre>";print_r($winterfell);echo "</pre>"; $table = NULL; $table .= '<h4>Patient Details</h4> <p>Name:' . $imp[0]['patient_names'] . '</p> <p>Age: ' . $imp[0]['age'] . '</p> <h4>Recent History</h4> <table class="table table-bordered"> <thead> <th>Commodity Code</th> <th>Commodity Description</th> <th>Issue type</th> <th>Amount</th> <th>Date of Issue</th> </thead> <tbody>'; foreach ($winterfell as $key) { $table .= '<tr> <td>' . $key['commodity_code'] . '</td> <td>' . $key['commodity_name'] . '</td> <td>' . $key['issue_type_desc'] . '</td> <td>' . $key['amount'] . '</td> <td>' . date('Y m d', $key['date_issued']) . '</td> </tr>'; } $table .= ' </tbody> </table>'; echo $table; }