我的网站收件箱页面上的每个循环都有一个:
<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>
我的实际视图页面上没有重复此行:
<td width="5%"><input name="sunny" id="sunny" type="checkbox" value="" class="" checked="checked" /></td>
基本上它是一个复选框的图像替换,当它被点击到勾选的图像或未勾选的图像时会发生变化。
此图像仅出现在我的数据库中第一个返回的消息中。从我的数据库中抓取的其他4条消息显示一个复选框,这是不正确的,因为应该有一个图像复选框,就像每个其他消息的第一条消息一样。我猜是因为没有任何php在该行中处理它没有被包含在foreach循环中。
此图片复选框的目的是让用户轻松识别他们设置为收藏的收件箱中的邮件。
我如何解决这个问题?![替代文字] [1]
答案 0 :(得分:4)
输出HTML肯定是正确重复的。我猜你会根据复选框的id
使用Javascript或CSS更改复选框的外观。每个复选框都有id="sunny"
,但这是不正确的。 id必须在页面上是唯一的。我想这就是为什么你的CSS / Javascript只影响第一个复选框。
如果您想要应用多个元素,请使用class
。