I have a for each loop on the inbox page of my website:
<table width="40%" border="0">
<tr><p id="links">
<a href="#" id="all" class="pseudo">all</a>,
<a href="#" id="none" class="pseudo active">none</a>,
<a href="#" id="read" class="pseudo">read</a>,
<a href="#" id="unread" class="pseudo">unread</a>,
<a href="#" id="replied" class="pseudo">replied</a>,
<a href="#" id="fav" class="pseudo">favourite</a>
</p>
<td width="5%"></td>
<td width="5%"></td>
<td width="22%"></td>
<td width="19%"></td>
<td width="60%"></td>
<td width="17%"></td>
</tr>
<?php foreach ($query as $row): ?>
<tr>
<?php switch($row['status']){
case 0: $status = "unread"; break;
case 1: $status = "read"; break;
case 2: $status = "replied"; break;
case 3: $status = "fav"; break;
default: $status = '';
}?>
<td width="5%"><input name="message" id="messages" type="checkbox" value="" class="<?php echo $status; ?>"/></td>
<td width="5%"><input name="sunny" id="sunny" type="checkbox" value="" class="" checked="checked" /></td>
<td><?php echo $status; ?></td>
<td><?php echo $row['from_user']; ?></td>
<td><div id="test"><a href="<?php echo site_url("messages/read_message/".$row['id']); ?>"><?php echo $row['subject'] . " " . $row['message']; ?></a></a></div></td>
<td><?php if ($row['date_sent'] == date('Y-m-d')) { echo $row['time_sent']; } else echo $row['date_sent']; ?></td>
</tr>
<?php endforeach; ?>
</table>
This line is not being repeated on my actual view page:
<td width="5%"><input name="sunny" id="sunny" type="checkbox" value="" class="" checked="checked" /></td>
Basically it’s a image replacement for a checkbox that changes when it’s clicked on to a ticked image or an unticked image.
This image is only appearing on the first returned message in my database. The other 4 messages that are grabbed from my database show a checkbox and this is incorrect because there should be an image checkbox just like the first message for every other message. I’m guessing because there isn’t any php to process in that line that it isn’t been included foreach loop.
The purpose of this image checkbox is to make it easy for users to recognise what messages in their inbox they have set to favourite.
How would I solve this?![alt text][1]
The output HTML is most certainly correctly repeated. I’d guess you change the looks of the checkbox using Javascript or CSS based on the
idof the checkbox. Every checkbox has theid="sunny"though, which is incorrect. An id needs to be unique on the page. I suppose that’s why your CSS/Javascript only affects the first checkbox.Use a
classif you have more than one element you want to apply something to.