DLR Posted June 28, 2006 Share Posted June 28, 2006 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? Quote Link to comment Share on other sites More sharing options...
wisewood Posted June 28, 2006 Share Posted June 28, 2006 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. Quote Link to comment Share on other sites More sharing options...
DLR Posted June 28, 2006 Author Share Posted June 28, 2006 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? Quote Link to comment Share on other sites More sharing options...
litebearer Posted June 28, 2006 Share Posted June 28, 2006 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.