Hey,
I've created a database where my users (joomla users and CB) can point out that they would like to recieve emails.
So now I'm trying to make a form that allows me to send a mail directly to all recipients.
This code gives me a nice overview of all the users their email, and with the echo I putted a , in between.
But I would like to put the echo now in a variable (?) so that I can use this later on in a mailform. When I put this into an array, I've got only the latest mail address (not all).
Any ideas/suggestion how I should do this?
Thanks!
I've created a database where my users (joomla users and CB) can point out that they would like to recieve emails.
So now I'm trying to make a form that allows me to send a mail directly to all recipients.
This code gives me a nice overview of all the users their email, and with the echo I putted a , in between.
$result = mysql_query("
SELECT email FROM voc_users
LEFT JOIN voc_comprofiler
ON voc_users.id = voc_comprofiler.user_id
WHERE cb_mailing = 1
");
while ($row = mysql_fetch_assoc($result)) {
echo "" . $row['email'] . ", ";
}
But I would like to put the echo now in a variable (?) so that I can use this later on in a mailform. When I put this into an array, I've got only the latest mail address (not all).
$result = mysql_query("
SELECT email FROM voc_users
LEFT JOIN voc_comprofiler
ON voc_users.id = voc_comprofiler.user_id
WHERE cb_mailing = 1
");
while ($row = mysql_fetch_assoc($result)) {
$form->data['mailarray'] = $row['email'];
}
Any ideas/suggestion how I should do this?
Thanks!
Hi brononius,
First, I don't think that the standard Email action will accept a variable with a string of emails in it; but my Email [GH] action will accept either a string or an array (it also has an option to send out separate emails to each address).
So this code would work I think:
Bob
First, I don't think that the standard Email action will accept a variable with a string of emails in it; but my Email [GH] action will accept either a string or an array (it also has an option to send out separate emails to each address).
So this code would work I think:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT `email`
FROM `#__users` AS u
LEFT JOIN `#__comprofiler` AS c
ON u.`id` = c.`user_id`
WHERE `cb_mailing` = 1 ;
";
$db->setQuery($query);
$form->data['to_emails'] = $db->loadResultArray();
?>
Bob
Is it normal that in a debug, the 'to_emails' stay empty?
If I run the sql query in phpmyadmin, the result is correct.
If I run the sql query in phpmyadmin, the result is correct.
Not sure if it's good, but this seems to work with your action:
$result = mysql_query("
SELECT email FROM voc_users
LEFT JOIN voc_comprofiler
ON voc_users.id = voc_comprofiler.user_id
WHERE cb_mailing = 2
");
while ($row = mysql_fetch_array($result)) {
$mailarray[] = $row['email'];
}
$form->data['to_emails'] = $mailarray;
Hi brononius,
If it works, it's OK.
Maybe loadAssocArray() doesn't work in the current Joomla! :-(
Bob
If it works, it's OK.
Maybe loadAssocArray() doesn't work in the current Joomla! :-(
Bob
This topic is locked and no more replies can be posted.