gpt4 book ai didi

php - 遍历行、更新并发送电子邮件

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

我在遍历行、更新字段、然后根据日期发送电子邮件时遇到问题。我也可以让第一行发送电子邮件,但我不明白为什么我无法让其他行发送电子邮件。我可以显示返回了三行,但我无法发送三封电子邮件。代码如下,提前感谢您的帮助。

<?php




for($numOfRows = 1; $numOfRows > 0;){

$sql = "SELECT * FROM service WHERE boosterDate BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY";

if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}

$numOfRows = $result->num_rows;
//%result->store_result();
$numOfRows = var_dump($numOfRows);
//echo $numOfRows;

//if($numOfRows > 0){

//var_dump($numOfRows);

while($row = $result->fetch_array()){
//Get all the rows and store them in an array
$firstQueryRows[] = $row;

}

foreach($firstQueryRows as $row){

//do a new query with $row
$serviceID = $row['serviceID'];
$patientID = $row['patientID'];
$serviceName = $row['serviceName'];
$price = $row['price'];
$quantity = $row['quantity'];
$boosterDate = $row['boosterDate'];
$totalPrice = $row['totalPrice'];
$rabiesTagNumber = $row['rabiesTagNumber'];
$microChipNumber = $row['microChipNumber'];
$rabiesDose = $row['rabiesDose'];
$rabiesVacType = $row['rabiesVacType'];

$rabiesVacExpDate = $row['rabiesVacExpDate'];
$rabiesSerialNumber = $row['rabiesSerialNumber'];
$rabiesManufacturer = $row['rabiesManufacturer'];
$rabiesVacDate = $row['rabiesVacDate'];
$rabiesVacDueBy = $row['rabiesVacDueBy'];
$licenseNumber = $row['licenseNumber'];
$isThisARabiesCert = $row['isThisARabiesCert'];
$vacDate = $row['vacDate'];
$email30 = $row['email30'];
$email60 = $row['email60'];
$email90 = $row['email90'];
//echo $serviceID . " ";
$sql = "UPDATE service SET email30 = 30 WHERE serviceID = $serviceID";

if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}

}//End Foreach



//echo $patientID;


$sql = "SELECT * FROM service WHERE email30 = 30";
if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}

while($row = $result->fetch_array()){
//Get all the rows and store them in an array
$firstQueryRows[] = $row;

$patientID = $row['patientID'];
//echo $patientID;

}

foreach($firstQueryRows as $row){



$sql = "SELECT * FROM patientInformation WHERE patientID = $patientID";
if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}

}

while($row = $result->fetch_array()){
$firstQueryRows[] = $row;
$clientID = $row['clientID'];
$maleFemale = $row['maleFemale'];
$species = $row['species'];
$ageYears = $row['ageYears'];
$ageMonths = $row['ageMonths'];
$weight = $row['weight'];
$dogBreed = $row['dogBreed'];
$name = $row['name'];
$catBreed = $row['catBreed'];
$colors = $row['colors'];
$illnessLast30Days = $row['illnessLast30Days'];
$explainIllness = $row['explainIllness'];


//echo $clientID;

}

foreach($firstQueryRows as $row){

$sql = "SELECT * FROM clientInformation WHERE clientID = $clientID";
if(!$result = $con->query($sql)){
die('There was an error running the query [' . $con->error . ']');
}

}

while($row = $result->fetch_array()){

$firstName = $row['firstName'];
$lastName = $row['lastName'];
$address = $row['address'];
$city = $row['city'];
$zip = $row['zip'];
$phone = $row['phone'];
$cell = $row['cell'];
$state = $row['state'];
$email = $row['email'];




}

$to = $email;
$subject = "Just a friendly reminder from the Shot Spot";


$message = "Greetings " . $firstName . " " . $lastName . "\r\n" . "\r\n" . "\r\n" .
"Thank you for choosing the Shot Spot for all of your animals healthcare needs. This is a friendly reminder that
" . $name . " is ready for their booster on " . $boosterDate . "\r\n" . "\r\n" . "\r\n" .
"Thank you for choosing the Shot Spot";


$headers = 'From: info@txshotspot.com';

mail($to, $subject, $message, $headers);



}//end for loop


?>

最佳答案

您没有通过 for 循环进行迭代,并且您的代码有点困惑 :p 。您想发送三封电子邮件,请尝试以下操作:

for($numOfRows = 0; $numOfRows <= 3; $numOfRows++)

关于php - 遍历行、更新并发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19943698/

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