Jump to content

Is It Possible To Have What I Want?


DLR

Recommended Posts

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:

[code]$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);[/code]

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?
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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

[code]       while ($row = mysql_fetch_array($result)) {[/code]

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

Lite...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.