Forums

CF8 - DB Read / Loop / E-Mail

rbock 27 Feb, 2024
Good day!

I would like to read several data records from a DB and send them formatted via email. I can display the data via loop, but I can't send it by email.
rbock 01 Mar, 2024
Answer
1 Likes
Ok... I solved it... I read the array with a PHP script and then pass the formatted table to the mail action.
rbock 01 Mar, 2024
Can be marked as solved!
mari4anna87433 08 Mar, 2024
Can you share your php script?
Thank you
rbock 09 Mar, 2024
function my_table($array){
$html = '<table>';
$html .= '<tr>';
foreach($array[0] as $k1=>$v1){
$html .= '<th>' . htmlspecialchars($k1) . '</th>';
}
$html .= '</tr>';

foreach( $array as $k1=>$v1){
$html .= '<tr>';
foreach($v1 as $k2=>$v2){
$html .= '<td>' . htmlspecialchars($v2) . '</td>';
}
$html .= '</tr>';
}

$html .= '</table>';
return $html;
}

$array = $this->get("data");

return my_table($array);
You need to login to be able to post a reply.