jopo Posted October 10, 2008 Share Posted October 10, 2008 I am trying to create a php script that emails all the rows of a table at certain time intervals using cron. How do I pass in all the rows to the mail function? I can only seem to get the last row emailed to me. Quote Link to comment Share on other sites More sharing options...
aebstract Posted October 10, 2008 Share Posted October 10, 2008 We're gonna most likely need to see your code that you're working with. It'd be pretty hard to tell why all of your rows aren't sending without seeing what you are doing. Quote Link to comment Share on other sites More sharing options...
jopo Posted October 10, 2008 Author Share Posted October 10, 2008 Yikes . Well, this is what I have so far but do not think I am approaching the solution correctly. while($row=mysql_fetch_array($result)){ $message= "Name: ".$row['name']; echo $message; } $email="***@***.com"; $to = $email; $subject = "Test"; mail($to, $subject, $message); Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 10, 2008 Share Posted October 10, 2008 You are overwriting the value of $message each time through the loop. Here's how I would do this: <?php $tmp = array(); while($row=mysql_fetch_array($result)){ $tmp[] = "Name: ".$row['name']; } $email="***@***.com"; $subject = "Test"; mail($email, $subject, implode("\n",$tmp)); ?> Ken Quote Link to comment Share on other sites More sharing options...
jopo Posted October 10, 2008 Author Share Posted October 10, 2008 Thanks! 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.