所以基本上,我的网站向用户显示一份工作清单,包括其详细信息,日期和到期日期。现在用户可以删除作业,我要添加的是自动删除。所以工作应该在到期日期过后自行删除,我不确定最好的方法。
这是将作业从数据库中显示出来的代码,以及一个删除语句,允许用户根据他们选择的内容手动删除作业。
function getJobs($conn)
{
//$query = "SELECT * FROM jobs";
$query = "SELECT * FROM job WHERE user_ID = :user_ID";
$stmt = $conn->prepare($query);
//$stmt->bindValue(':user_ID', $_SESSION["user_ID"]);
$stmt->bindValue(':user_ID', $_SESSION['user_ID']);
$stmt->execute();
$workers=array();
while($worker=$stmt->fetch(PDO::FETCH_OBJ))
{
$workers[]=$worker;
}
return $workers;
}
//INNER JOIN driver ON jobs.user_ID = driver.user_ID
function getAllJobs($conn)
{
//$query = "SELECT * FROM jobs";
$query = "SELECT * FROM job WHERE admin_id = :admin_id";
$stmt = $conn->prepare($query);
$stmt->bindValue(':admin_id', $_SESSION['user_ID']);
$stmt->execute();
$workers=array();
while($worker=$stmt->fetch(PDO::FETCH_OBJ))
{
$workers[]=$worker;
}
return $workers;
}