gpt4 book ai didi

php每日电子邮件报告

转载 作者:行者123 更新时间:2023-11-29 03:03:17 24 4
gpt4 key购买 nike

我创建了一个 CRON 作业,每天早上 8 点 30 分运行,以便将报告发送到特定的电子邮件地址。但是,该报告对输入特定日期的用户有效。我想知道如何将 $_post 值从开始和结束日期变量更改为“今天”和昨天的日期。

代码如下:

session_start();  
$s = $_POST['$yesterday'];
$e = $_POST['$today'];
$i = $_SESSION['user'];
$m = "VACANCY APPLICATIONS REPORT FROM $s TO $e \r\n\r\n";
$conn = mysqli_connect("");

$em = "email address";
$vrquery = "SELECT jobid,role,jobtype,vacancyref FROM job ORDER BY jobid";

$vrresult = mysqli_query($conn, $vrquery);
while($vrrow=mysqli_fetch_array($vrresult))
{
$m = $m . $vrrow['vacancyref'] . " " . $vrrow['role'] . " " . $vrrow['jobtype'] . "\r\n\r\n";
$vquery = "SELECT cname,ctel,cemail FROM candidatejob,cv,candidate WHERE jobid=".$vrrow['jobid']." AND candidatejob.cvid=cv.cvid AND cv.cid=candidate.cid AND cvdate>='$s' AND cvdate<='$e' ORDER BY cname";
$vresult = mysqli_query($conn, $vquery);
while($vrow=mysqli_fetch_array($vresult))
{
$m = $m . $vrow['cname'] . " " . $vrow['ctel'] . " " . $vrow['cemail'] . "\r\n";
}
$m = $m . "\r\n\r\n";
}
$m = $m . "\r\n\r\nALL CANDIDATES SUBMITTING CVs WITHIN DATES\r\n\r\n";
$cvquery = "SELECT cname,ctel,cemail FROM cv,candidate WHERE cv.cid=candidate.cid AND cvdate>='$s' AND cvdate<='$e' ORDER BY cname";
$cvresult = mysqli_query($conn, $cvquery);
while($cvrow=mysqli_fetch_array($cvresult))
{
$m = $m . $cvrow['cname'] . " " . $cvrow['ctel'] . " " . $cvrow['cemail'] . "\r\n";
}

$conn->close();


$headers = "From: no-reply@nortech.org.uk\r\nX-Mailer: PHP/" . phpversion();
mail($em, " Daily Job Applications Report", $m, $headers);

?>

cron 作业运行良好,但是它没有从数据库返回任何结果。我知道连接是正确的,因为它在我所有的页面上都是一样的,而且它们都有效。任何人都可以帮助并提供有关为什么它不从数据库中提取的建议吗?

非常感谢

最佳答案

要获取今天的日期,请遵循上面的编码风格:

$e = date("Y-m-d");

获取昨天的日期:

$s = date("Y-m-d", strtotime("-1 day"));

http://php.net/manual/en/function.date.php

另外,为什么在 $_POST 变量名称中有美元符号?

关于php每日电子邮件报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19859246/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com