可以选中多个邮件前的复选框,点击按钮"标记已读",将这几个邮件的状态改为"已读",在 updateWrite.php 页面的 updateWrite 函数里书写修改邮件状态的代码。
(1)在 updateWrite.php 页面 updateWrite 函数里书写代码
使用 PDO 方式,链接操作 MySQL 数据库,执行 update 语句,根据用户传入的参数 $arr($arr的值对应的数据表的id值),将$arr中值对应的数据状态全都改为“已读“
备注:数据表 email 结构:
id 自增序号
title 标题
send 发送人
date 发件时间
type 状态
这是我的代码,希望大佬能够改一下我的update语句,谢谢!
<?php
header("content-type:text/html;charset=utf-8");
$ids = $_POST["ids"];
function updateWrite($arr){
//$url,$user,$pwd是自动生成的数据库相关信息,不能修改
//连接数据库时不需要写端口号
$url = "mysql:host=mysql;dbname=database_25523_19_91526";//数据库ip和库名
$user = "25523_19_91526";//数据库用户
$pwd = "357ac811692c154075a0270d4dc9b27f";//数据库密码
$sql="update email set arr="已读" where ids='$arr'";
$conn = new PDO($url,$user,$pwd);
$result = $conn->exec($sql);
}
updateWrite($ids);
?>