Jump to content

[SOLVED] [MySql/PHP] Parsing array items with comma


chenci

Recommended Posts

Hi, i've been working in this code and it seems to have some problems. This is what i want to do

1)A query to select all the users who have recievemail = YES

2)Fetch all the email from the query to an array and put commas to one after another

3)The echo would be something like this

google@gmail.com,microsoft@hotmail.com,newguy@new.com,and so on

 

$query = "SELECT * FROM " .s('prefix'). "users WHERE recievemail = 'YES' ORDER BY id DESC";
$result  = mysql_query($query);
$n[] = mysql_fetch_array($result);
foreach ($n as $e)
{
	$mails = $e['email'];
        	$multiplemails .= $mails . ",";
	echo $multiplemails;

And this is what i got

messinanahuel@hotmail.com,

Very weird isn't it? Only one email, and i went to phpmyadmin and there a lot of users with recieve mail = YES. Seems not touching PHP for half a year, can get you now a dose of insanity with this code, as i can't figure out where is wrong.

Mysql version: 5.0.81

Any ideas? Thanks for the time anyway.

Chenci

Link to comment
Share on other sites

Try this...

 


$query = "SELECT * FROM " .s('prefix'). "users WHERE recievemail = 'YES' ORDER BY id DESC";
$result  = mysql_query($query);
while ($row = mysql_fetch_array($result )) {
      $mails[] = $row['email'];
}

 

Now you have an array with all of your email addresses, Just create the , delimited field now

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.