Jump to content


This topic is now archived and is closed to further replies.


Is It Possible To Have What I Want?

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)) {
             //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

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?

Share this post

Link to post
Share on other sites
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.

Share this post

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

Share this post

Link to post
Share on other sites

$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 ...
$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.


Share this post

Link to post
Share on other sites


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.