Re: Needing help hear

From: Date: Tue, 15 May 2001 09:37:58 +0000
Subject: Re: Needing help hear
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52821@lists.php.net to get a copy of this message
Hi Richard, I *always* get this word wrong, but here goes.... You need to "concantenate" (grimace), which means (simply) "add to" to the variable, using .= Modify your code slightly: <? $recipient = ""; $result = @mysql_query($sql); $num_rows = mysql_num_rows($result); while($myrow = mysql_fetch_array($result)) { $email = $myrow['email']; $recipient .= $email . ","; } ?> Notice the .= before $recipient = $email.... ? Also why, is the $num_rows in there? It's not being used for anything. If you might have blank emails in there, you could make good use of the num rows..... <? $recipient = ""; $result = @mysql_query($sql); $num_rows = mysql_num_rows($result); $x = 0; while($myrow = mysql_fetch_array($result)) { $email = $myrow['email']; if (isset($email)) { $recipient .= $email . ","; $x++; } } echo "Email sent to " . $x . " number of people, out of " . $num_rows . " residing in the database."; ?> Hope that helps, James. "Richard Kurth" <rkurth@pacifier.com> wrote in message news:13204409143.20010515011610@pacifier.com... > > I am trying to pull all the e-mail out of the database and put them > in a format like this me@domain.com,me2@domain.com,me3@domain.com > this is what I have now but I don't seam to be going in the right > direction. Could somebody give me a hint > > $sql = "SELECT email FROM customers"; > $result = mysql_query($sql); > $num_rows = mysql_num_rows($result); > > while ($myrow = mysql_fetch_array($result)){ > > $recipient=$myrow["email"] . ","; > } > > > > > > > > > > > > > > > > > Best regards, > Richard > mailto:rkurth@pacifier.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#52821) next »