Sending email depending on selection in Form. Need Help with ARRAY!

I am working with joomla and fabrik.

I have a form were depending on the selected country an email is send to different user(s).
This works fine with following code:
[php]
$db =& JFactory::getDBO();$db->setQuery
(“SELECT email FROM location_addresses
WHERE country = ‘{flughafen___select_country}’”);
return $db->loadResult();[/php]

As you see it gets the email from the table: location_addresses. In the email from each country I can put several emailadresses seperated with a , which works fine as well.

But what I WANT does not work: wenn I have the same country several times in the table with different email adresses it only sends the email to the first selected country:

In following case the email only goes to [email protected]

country email
AUSTRIA [email protected]
AUSTRIA [email protected]

I think there must be put an ARRAY in the php code, but I have got no idea how to do this. Can anybody help me with this?

Thank you very much in advance.

Greetings from Austria,
Seven

please provide more information… on the script

if ‘flughafen___select_country’ this is a variable, ensure it has $ as prefix…

Hi byraja,
The script is working.

‘flughafen__select_country’ is the country selector.
‘email’ from the table ‘location addresses’ is (I think) the variable.

Seven

glad it worked,

what was wrong before?

hi byjara,

sorry I expressed myself wrong.
[i]Hi byraja,
The script is working.

‘flughafen__select_country’ is the country selector.
‘email’ from the table ‘location addresses’ is (I think) the variable.
[/i]

I mean that the original script is working: [php]$db =& JFactory::getDBO();$db->setQuery
(“SELECT email FROM location_addresses
WHERE country = ‘{flughafen___select_country}’”);
return $db->loadResult();[/php]

But what I WANT does not work: when I have the same country several times in the table with different email adresses it only sends the email to the first selected country:

In following case the email only goes to [email protected]

country email
AUSTRIA [email protected]
AUSTRIA [email protected]

So the variable would be email. But how would the script look like to get all the email addresses out of the table?

Thanks for your time,

Seven

Okay I have via the administrator rob of www.fabrikar.com the solution.
I’m working with joomla & fabrik.

His words…the issue with that is that the code will stop executing at the first return, and only return the first email

what you need to do is return a comma separated list of emails, the code below should do that for you:

[php]
$db =& JFactory::getDBO();$db->setQuery
(“SELECT email FROM location_addresses
WHERE country = ‘{flughafen___select_country}’”);
return implode(’,’, $db->loadResultArray());
[/php]

Thank you all for looking into this.

Seven

Sponsor our Newsletter | Privacy Policy | Terms of Service