[eluser]PixelPanic[/eluser]
I'm coding a Day Planner for my Office Staff to help organize jobs as it will be on a Big TV
It only needs to show 5 days work (Mon-Fri) AND does not need to be continuous in days. Just a static Mon-Fri and data will be changed as and when needed etc. Hope that makes sense.
Each day is split into AM/PM and should allow for multi events for each staff member in AM/PM (EG Two events for a user in AM)
But I have run into a problem. I have the data outputting BUT it's not exporting multi events per AM/PM etc. It's only doing it for one event on each AM/PM etc
Example is in the SQL "This is a double test"
My SQL
Code:
CREATE TABLE IF NOT EXISTS `Planner` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Staff_ID` int(11) NOT NULL,
`Day` varchar(2) NOT NULL,
`event` text NOT NULL,
`time` varchar(5) NOT NULL DEFAULT 'AM',
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
INSERT INTO `Planner` (`ID`, `Staff_ID`, `Day`, `event`, `time`) VALUES
(1, 1, '1', 'Testing', 'AM'),
(2, 2, '1', 'Testing This', 'AM'),
(3, 2, '2', 'Testing Day 2', 'AM'),
(4, 2, '2', 'This is a double test', 'AM');
CREATE TABLE IF NOT EXISTS `Staff` (
`Staff_ID` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(100) NOT NULL,
`Tier` int(1) NOT NULL,
`Email` varchar(100) NOT NULL,
PRIMARY KEY (`Staff_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
INSERT INTO `Staff` (`Staff_ID`, `Name`, `Tier`, `Email`) VALUES
(1, 'Daniel', 1, ''),
(2, 'Test User', 1, '');
In my Controller all i have is
Code:
$data['staff'] = $this->db->get('Staff');
and ofcourse the standard view output
In my view
Code:
<div class="datagrid">
<pre>
</pre>
<table>
<thead>
<tr>
<th></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
</thead>
<tbody>
<?php foreach ($staff->result() as $row): ?>
<tr>
<td><?= $row->Name;?></td>
<td><table>
<?php $day1a = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','1')->where('time','AM')->get('Planner')->row(); ?>
<?php $day1p = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','1')->where('time','PM')->get('Planner')->row(); ?>
<tr>
<td none;">AM: <?=@$day1a->event;?></td>
</tr>
<tr>
<td none;">PM: <?=@$day1p->event;?></td>
</tr>
</table></td>
<td><table>
<?php $day2a = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','2')->where('time','AM')->get('Planner')->row(); ?>
<?php $day2p = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','2')->where('time','PM')->get('Planner')->row(); ?>
<tr>
<td none;">AM: <?=@$day2a->event;?></td>
</tr>
<tr>
<td none;">PM: <?=@$day2p->event;?></td>
</tr>
</table></td>
<td><table>
<?php $day3a = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','3')->where('time','AM')->get('Planner')->row(); ?>
<?php $day3p = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','3')->where('time','PM')->get('Planner')->row(); ?>
<tr>
<td none;">AM: <?=@$day3a->event;?></td>
</tr>
<tr>
<td none;">PM: <?=@$day3p->event;?></td>
</tr>
</table></td>
<td><table>
<?php $day4a = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','4')->where('time','AM')->get('Planner')->row(); ?>
<?php $day4p = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','4')->where('time','PM')->get('Planner')->row(); ?>
<tr>
<td none;">AM: <?=@$day4a->event;?></td>
</tr>
<tr>
<td none;">PM: <?=@$day4p->event;?></td>
</tr>
</table></td>
<td><table>
<?php $day5a = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','5')->where('time','AM')->get('Planner')->row(); ?>
<?php $day5p = $this->db->where('Staff_ID', $row->Staff_ID)->where('Day','5')->where('time','PM')->get('Planner')->row(); ?>
<tr>
<td none;">AM: <?=@$day5a->event;?></td>
</tr>
<tr>
<td none;">PM: <?=@$day5p->event;?></td>
</tr>
</table></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
If this is not correct would someone please mind helping and showing me please, as I have now reached a dead end. It's doing my head in xD