/    Sign up×
Community /Pin to ProfileBookmark

I need help with a array. Here is what i am trying to do. I have a sql database that has 2 col in it. col a “switch” col b “Emailaddress” so database would llok like this:
AAALT [email][email protected][/email]
AAALT [email][email protected][/email]
AALTEST2 [email][email protected][/email]
AALTEST2 [email][email protected][/email]

This is what i want to do. I want to send a email to the persons that is in the database. But i want to combined the names to one email that have the same col a. So if i run this it should send out 2 different emails. 1 for AAALT in the subject and then person with that in col a, 1 for AALTEST2 in the subject and then person with that in col a.
i can get it into a array. I just cant figure out on how to step through it to get the information that i need.
Below is the code that i have so far:

[code=php]while($r[]=mysql_fetch_array($getBWM));
{
echo “<pre>”;
array_pop($r);
print_r($r);
[/code]

Here is the output of it.
Array
(
[0] => Array
(
[0] => AAALT
[Switch] => AAALT
[1] => [email][email protected][/email]
[Emailaddress] => [email protected]
)

[1] => Array
(
[0] => AAALT
[Switch] => AAALT
[1] => [email protected]
[Emailaddress] => [email protected]
)

[2] => Array
(
[0] => AALTEST2
[Switch] => AALTEST2
[1] => [email protected]
[Emailaddress] => [email protected]
)

[3] => Array
(
[0] => AALTEST2
[Switch] => AALTEST2
[1] => [email protected]
[Emailaddress] => [email protected]
)

)

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@rwtrwt2003authorNov 09.2011 — so This is what i have so far:
[code=php]while($r[]=mysql_fetch_assoc($getBWM));
{
echo "<pre>";
array_pop($r);
print_r($r);
echo "</pre>";
foreach ($r as $key => $value)
{
echo "<pre>";
print_r ($value);
echo "</pre>";

foreach ($value as $key1 => $value1)
{
echo "<pre>";
print_r($value1);
echo "</pre>";
}
$e=array();
if ($key1 == $key1)
{
for ($i=0; $i< sizeof($key1); $i++)
{
$e[]=$value1[$i];
}
}
$e=implode($e,",");
echo $e;
[/code]

This is what i get

Array

(

[0] => Array

(

[Switch] => AAALT

[Emailaddress] => [email protected]

)

[1] => Array
(
[Switch] => AAALT
[Emailaddress] => [email protected]
)

[2] => Array
(
[Switch] => AALTEST2
[Emailaddress] => [email protected]
)

[3] => Array
(
[Switch] => AALTEST2
[Emailaddress] => [email protected]
)


)

Array

(

[Switch] => AAALT

[Emailaddress] => [email protected]

)

AAALT

[email protected]

b

Array

(

[Switch] => AAALT

[Emailaddress] => [email protected]

)

AAALT

[email protected]

r

Array

(

[Switch] => AALTEST2

[Emailaddress] => [email protected]

)

AALTEST2

[email protected]

d

Array

(

[Switch] => AALTEST2

[Emailaddress] => [email protected]

)

AALTEST2

[email protected]

m

Can anybody help me. I am trying to do a email list by Switch and combined the emails per Switch so i only send 2 emails instead of 4
×

Success!

Help @rwtrwt2003 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...