I want to pass the result of a mysql query to a variable that intergrades the email of our database to Mailchimp! However i don't know how to pass the mysql result to a variable!
More precise the query is:
$sql = "SELECT email, DATE_FORMAT(users.reg, '%Y-%m-%d') FROM users
WHERE DATE(reg) = CURDATE()";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
echo " " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}
$data = [
'email' => $row["email"],
'status' => 'subscribed'
];
syncMailchimp($data);
How can I pass the result of the query to $data email?
$data = ...,$rowwill befalse