I have a database with the following fields
- ID
- title
- URL
- summary
This data is stored in a multi dimensional associative array like this:
$array[0][title] = Title-1
$array[0][summary] = Summary-1
$array[1][title] = Title-2
$array[1][summary] = Summary-2
I also have a script that can loop through these and render as needed.
However I'm finding it tough getting this output into the body of a mail.
Looking around got me the following
- Dynamic Content into mail() $message
- Dynamic HTML Table in PHP Mail
- HTML mail with dyanmic values
- How to send HTML Dynamic Table as mail in php?
I found many more solutions via google, but they're more or less similar to the one's above.
These have not been helpful as the content is part static and part dynamic. In my case the whole body would be dynamic
Here's what I have as of now
function get_mailer_contents($email_category) {
global $mailer_contents;
$fetch_mailer_contents = mysql_query("SELECT * from `selected_posts` WHERE industry='$email_category'");
$id = "0";
while($temp_mailer_contents = mysql_fetch_array($fetch_mailer_contents))
{
$mailer_contents[$id]['title'] = $temp_mailer_contents['title'];
$mailer_contents[$id]['description'] = $temp_mailer_contents['description'];
$id ++;
}
}
get_mailer_contents($email_category);
foreach($mailer_contents as $title_cat)
{
echo "==================";
echo "<br>";
echo $title_cat['title'];
echo "<br>";
echo $title_cat['description'];
echo "<br>";
}
The output rendered here is not the final output. I'm using this just for testing purpose.
My problem is, a foreach function(or anything similar that would loop through the array) cannot be part of $message(body of the mail) mailer and I need to have a mechanism as the data is dynamic
Hope I have been clear enough. Do let me know if you need more specifics