General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 11th, 2003, 07:17 PM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 7
Send a message via AIM to Vasarab69
Post please help: using the while loop with commas

hello-

i'm working on a script which a monthly newsletter can be sent from the browser to all of the users which selected to get the newsletter when they registered (database table named 'newsletter' with a value of either 'Yes' or 'No')...i have no clue how to get the info from the db in comma-like form...so that it includes the address like "foo1@bar.com, f00foo@bar-bie.com, foo223@bar.com" ETC., but not having the last address have a comma after it.

how could i use the while loop (im guessing) to do this? thanks!
__________________
-Alexander

Last edited by Vasarab69 : February 11th, 2003 at 10:04 PM.

Reply With Quote
  #2  
Old February 12th, 2003, 03:33 AM
vlasblom vlasblom is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Netherlands
Posts: 14 vlasblom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 45 sec
Reputation Power: 0
Alexander,

Using the rtrim function will do the trick.
Depends how you extract the records from your database, but I'm thinking of something looking like this:
PHP Code:
 $strAddress "";
$strSQL "SELECT email FROM newsletter WHERE selected = 'Yes'";
$query mysql_query($strSQL) or die(mysql_error());
if(
mysql_num_rows($query) > 0)
{
    
// Concatenate all email addresses into a single address string
    
while($result mysql_fetch_array($query))
    {
         
$strAddress .= "$result[email], ";
    }
     
     
// Remove last comma and space
     
rtrim$strAddress", " );


Regards,
Arjon

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > correct usage of the while loop...need help please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT