I am trying to get each result of a query into one variable so that I can include it into my wp_mail message.
This is what I am using.
$result = $wpdb->get_results("SELECT *
FROM $tableName
WHERE userId = $user_ID
AND status LIKE '1'"
);
foreach( $result as $key => $value)
{
$string .= $value.',';
}
echo $string;
$email = $_POST['parentsEmail'];
$child = $_POST['childsName'];
wp_mail( $email, "".$child." has finished", "".$child." has completed the following ".$string." ");
I have been searching and found another thread asking something similiar and this was suggested.
$string .= $value.',';
However when I try to do the same thing, I get
Catchable fatal error: Object of class stdClass could not be converted to string in
$result? do print_r or var_dump