[eluser]Unknown[/eluser]
HI there all. I am new to codeigniter/php and I am confused as to where/ how to loop through the results to give two tables side by side
what I have now is very standard, I query the database and return the results except for those with "ongoing impacts". The results are then passed to the view and displayed.
I believe it will require a loop and splitting the results into two? Any help would be appreciated. I believe the code should be in the controller?
Currently:
Table 1
--------
Table 2
Desired Result:
Table 1 | Table 2
This is my code in my controller
Code:
<?php
class Outage extends Controller {
function Outage()
{
parent::Controller();
}
function index()
{
$data['query'] = $this->db->get_where('sysoutage', array('status !=' => 'Ongoing Impact'));
$this->load->view('outage_view', $data);
}
}
?>
This is the code in the view
Code:
<html>
<head>
<title>Outages Page</title>
<link href="/outage.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<?php foreach($query->result() as $row): ?>
<table width="500px">
<tr>
<td align="center"><?=$row->sysoutpic?></td>
<td colspan="3" align="center" class="outagesysname"><?=$row->systemname?></td>
</tr>
<tr>
<td class="rowodd">Status:</td><td class="rowodd"><?=$row->status?></td>
<td class="rowodd">Helpdesk Ref:</td><td class="rowodd"><?=$row->helpdeskref?></td>
</tr>
<tr>
<td class="roweven">Fault Description:</td><td colspan="3" class="roweven"><?=$row->faultdesc?></td>
</tr>
<tr>
<td class="rowodd">Impact:</td><td colspan="3" class="rowodd"><?=$row->impact?></td>
</tr>
<tr>
<td class="roweven">Workaround:</td><td colspan="3" class="roweven"><?=$row->workaround?></td>
</tr>
<tr>
<td class="rowodd">Script:</td><td colspan="3" class="rowodd"><?=$row->script?></td>
</tr>
<tr>
<td class="roweven">Time Started:</td><td class="roweven"><?=$row->timeentered?></td>
<td class="roweven">Entered By:</td><td class="roweven"><?=$row->enteredby?></td>
</tr>
</table>
<hr />
<?php endforeach; ?>
</body>
</html>