arrays and email

From: Date: Tue, 29 Jan 2002 19:14:21 +0000
Subject: arrays and email
Groups: php.db 
Request: Send a blank email to php-db+get-16281@lists.php.net to get a copy of this message
I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: <? $sql = "select * from webusers where webdate=\"$webdate\""; $result = mysql_query($sql) or die("couldn't generate a list of the users"); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo "<form method=\"post\" action=\"doemailattendees.php\">\n"; echo "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0 class=\"orange4\">\n"; echo "<tr>\n"; echo "<td valign=\"top\"><p><b>To:</b></p></td>\n"; echo "<td valign=\"top\"><p>\n"; foreach ($list as $value) { print "$value, "; $to = $value; } echo "</p></td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>\n"; echo "<tr>\n"; echo "<td valign=\"top\"><p><b>Subject:</b></p></td>\n"; echo "<td valign=\"top\"><p><input type=\"text\" name=\"subject\"</p></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td valign=\"top\"><p><b>Message:</b></p></td>\n"; echo "<td valign=\"top\"><textarea name=\"message\"></textarea></td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td colspan=2 valign=\"top\"><input type=\"submit\" value=\"submit\"></td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</form>\n"; ?> The $to, $subject, & $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com

« previous php.db (#16281) next »