Welcome Guest, Not a member yet? Register   Sign In
Confused how to loop to produce tables side by side
#1

[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">&lt;?=$row->sysoutpic?&gt;</td>
<td colspan="3" align="center" class="outagesysname">&lt;?=$row->systemname?&gt;</td>
</tr>
<tr>
<td class="rowodd">Status:</td><td class="rowodd">&lt;?=$row->status?&gt;</td>
<td class="rowodd">Helpdesk Ref:</td><td class="rowodd">&lt;?=$row->helpdeskref?&gt;</td>
</tr>
<tr>
<td class="roweven">Fault Description:</td><td colspan="3" class="roweven">&lt;?=$row->faultdesc?&gt;</td>
</tr>
<tr>
<td class="rowodd">Impact:</td><td colspan="3" class="rowodd">&lt;?=$row->impact?&gt;</td>
</tr>
<tr>
<td class="roweven">Workaround:</td><td colspan="3" class="roweven">&lt;?=$row->workaround?&gt;</td>
</tr>
<tr>
<td class="rowodd">Script:</td><td colspan="3" class="rowodd">&lt;?=$row->script?&gt;</td>
</tr>
<tr>
<td class="roweven">Time Started:</td><td class="roweven">&lt;?=$row->timeentered?&gt;</td>
<td class="roweven">Entered By:</td><td class="roweven">&lt;?=$row->enteredby?&gt;</td>
</tr>
</table>
<hr />

&lt;?php endforeach; ?&gt;

&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]obiron2[/eluser]
I would suggest this is a job for DIVs and CSS




Theme © iAndrew 2016 - Forum software by © MyBB