Jump to content


Photo

Is It Possible To Have What I Want?


  • Please log in to reply
3 replies to this topic

#1 DLR

DLR
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationJohannesburg, South Africa

Posted 28 June 2006 - 11:02 AM

Hi all.

I have a birthday list in a table and have written a script that will lookup and find those people who's birthday it is today. The PHP programme then sends off an email to each person. Now, what I would like to be able to do is have ONE email sent to "me" that lists ALL the people having a birthday today - rather than a copy of each email that is sent to the birthday person.

Here's what I have done so far:

$check_birthdays = "SELECT * FROM birthdays WHERE day = $today_day AND month = $today_month";
$result = mysql_query($check_birthdays) or die(mysql_error());

if (mysql_num_rows($result) >> 0 ) {

        //send email to each person who has a birthday today
        while ($row = mysql_fetch_array($result)) {
            extract($row);
            birthday_wishes();
             //I have left off the code for  the function  birthday_wishes() as it works fine
        }
        // send one email with list of all people having birthday today
        birthday_list();

function birthday_list() {
global $row;
$to = "me";
$subject = "Today's birthday list";
$messagebody = "The following clients have birthdays today, " . date('d/F/Y') . " <p> " . print_r($result);

The print_r($result) gives something like Resource ID#4 as opposed to a list of names etc.

I have left off the rest of the email code as it works fine too.

Any suggestions?

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 28 June 2006 - 11:07 AM

first you need to make sure you can echo the results of your query onto the page. Once you have that right, you will be able to do what you want.
wisewood: proven fact, I am both wise, and wooden.

#3 DLR

DLR
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationJohannesburg, South Africa

Posted 28 June 2006 - 11:35 AM

Hi,
Yes it does echo onto the email. But all I get is " The following clients have birthdays today" and the date - their actual information does not appear.

Is there a way of saving the data as it goes through the "while" loop in such a way that the array/variable/whatever can be echo'ed in the email?

#4 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 28 June 2006 - 11:48 AM

ok...

$result is simply a 'handle' that php/mysql uses to know to which query you are referring.

several ways to do it, one example (pseudo code)...


as you loop through your results

       while ($row = mysql_fetch_array($result)) {

simply add these lines ...
$bd_array[$ix] = the row values;
$ix = $ix + 1;
when it is finished, you will have any array whith which you can do anything you desire.

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users