我已经创建了一个收件箱,可以从mysqldb获取邮件。
我需要区分读取和未读电子邮件,我试图通过行中的内联样式来实现。 我在用户点击电子邮件并打开它时立即尝试这样做,在mysqldb中更改状态readstatus flag =" YES",这是" NO&# 34;默认情况下。
但是,它仅适用于第一行。
<form action="<?php echo BASEURL; ?>home/movetotrash" method="POST" id="emailform" enctype="multipart/form-data">
<center id="msg"></center>
<table align="center" cellpadding="10" border="1" class="mailbox">
<tr class="headrow">
<th>Select</th>
<th>From</th>
<th>E-mail</th>
<th>Subject</th>
<th>Date</th>
</tr>
<?php
$id="";
$read = 0;
$unread = 0;8*****-
foreach($row as $alldata)
{
$id = $alldata->ID;
if($alldata->READSTATUS=="YES"){
$read++;
echo "<tr id='".$alldata->ID."' bgcolor='lightgray'>";
}else{
$unread++;
echo "<tr id='".$alldata->ID."' bgcolor='white'>";
}
echo "<td><input type='checkbox' name='select[]' id='select' value=".$id." onclick='enablebtn()'></td>";
echo "<td class='mailcell' name='name[]' id='nameclick'>".$alldata->NAME."</td>";
echo "<td class='mailcell' name='sender[]' id='nameclick'>".$alldata->SENDER."</td>";
echo "<td class='mailcell' name='subject[]' id='nameclick'>".$alldata->SUBJECT."</td>";
echo "<td class='mailcell' name='date[]' id='nameclick'>".$alldata->DATE."</td>";
echo "</tr>";
}
?>
</table>
<button type="submit" class="btn-primary" name='movetotrash' id="movetotrash" disabled">Delete</button>
</form>
public function showemail()
{
$data['row'] = $this->user_model->inboxdb();
$data['sentemail'] = $this->user_model->sentemaildb();
$data['draftemail'] = $this->user_model->draftemaildb();
$data['trashemail'] = $this->user_model->trashemaildb();
$this->load->view('index',$data);
$data['emaildata'] = $this->user_model->showemaildb();
$id = $data['emaildata']->ID;
$this->user_model->changereadstatus($id);
$this->load->view("showemail", $data);
$this->load->view('footer');
}
public function changereadstatus($id)
{
$sql="update email set READSTATUS='YES' where ID='$id'";
$res = $this->db->query($sql);
return true;
}