Hi kevin,
Seems like in your while loop, you are not populating your list array
correctly with all the emails you have.
Try to have a count value and populate the array list accordingly such as:

    $count = 0;
    while ($row = mysql_fetch_row($result))
     {
      $real_name = $row[1];
      $email = $row[12];
      $list[$count] = $email;
      $count = $count + 1;
     }

Hope this helps.
Gurhan


-----Original Message-----
From: Kevin Ruiz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 2:14 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] arrays and email


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



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to