(made a correction in sudo code)

Ok, this one is breaking my back all day.
First some sudo-code ->

fuction email_to_user() {
      $sql = 'select distinct(email) from user';
      $emailfetch = mysql_query($sql);

      $sql = 'select news, date from news order by sid desc limit 10';
      $newsfetch = mysql_query($sql);

      while ($data = mysql_fetch_row($emailfetch)) {
          $container = array();
          $container[] = '<html><head><title></head><body>';

          $message = 'Have a nice day';
          $container[] = $message;
          while (list($news, $date) = mysql_fetch_row($newsfetch)) {
              $container[] = '<a href='newslink.php'>' . $news . '</a>';
              $container[] = '<br><hr><br>';
          $container[] = '</body></html>';
          $message2 = '';
          foreach($container as $foo) {
              $message2 .= $foo;
          mail(Send mail to $data[0], $message2);

Basically it grabs all the user's email addresses, then loop them.
On each loop grab all news items.
Then emails results to the user and moves on to the next user.

Im running this on my test box, that only has two users, but the 2nd
user never gets the expected results.
The first user get the message and the news.
The second only gets the message.
The code structure is pretty much unchanged from a working example till
I started using $container to hold array elements.

Could anyone see bad logic in the above code??

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to