
Originally Posted by
ScallioXTX
Thanks for your reply.
Can I just layout my objective in full, as I probably started 'half way up the ladder' with my initial post.
I think I have the send mail concept down now, however my ultimate objective is to send individual email reminders to hosting clients based on a MySQL query of 'remindDate' being CURDATE().
What I have done so far:
I have successfully pulled the required data from the database and output it in the browser.
This has resulted in multiple matches. My question is: How do I send individual reminder emails to these matched results?.
Please note: I have commented out the CURDATE() condition at this time to simplify debugging.
Any help greatly appreciated!
PHP Code:
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=xxxxxxxxxxx', 'xxxxxxxxxx', 'xxxxxxxxxxxxxx');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$error = 'Unable to connect to the database server.';
include 'error.html.php';
exit();
}
try
{
//$sql = 'SELECT * FROM renewals WHERE remindDate = CURDATE()';
$sql = 'SELECT renewals.id, domain, expireDate, remindDate, firstname
FROM renewals INNER JOIN subscriber
ON subscriberid = subscriber.id';
$result = $pdo->query($sql);
}
catch (PDOException $e)
{
$error = 'Error fetching expiry dates: ' . $e->getMessage();
include 'error.html.php';
exit();
}
foreach ($result as $row)
{
$remindDates[] = $row['firstname'] .' '. $row['domain'] . ' ' . $row['expireDate'];
}
include 'remindNow.html.php';
remindNow.html.php
PHP Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>List of Today's Hosting Renewals</title>
</head>
<body>
<?php
foreach ($remindDates as $remindDate): ?>
<blockquote>
<p><?php echo htmlspecialchars($remindDate, ENT_QUOTES, 'UTF-8');
?> </p>
</blockquote>
<?php endforeach; ?>
</body>
</html>
Bookmarks