yep, it's working now, thnx, o and also.. i have that loop with a foreach on the users how do i do a thing like:
foreach($users as $value, $id as value2)
i know thats wrong its just i need to get more values through the loop and i can put another loop inside that one as it ends up sending too many mails and it gets messy. Anyone know a way of doing it so that i use:
<?
include 'db.php';
$sql_days = mysql_query("UPDATE projects SET daysleft=daysleft -1 WHERE active='yes'") or die(mysql_error()); // take a day off
$sql_make_inactive = mysql_query("UPDATE projects SET active='no' WHERE daysleft='0'") or die(mysql_error()); // make projects with 0 days left inactive
$get_inactive_users = mysql_query("SELECT * FROM projects WHERE active='no' AND notifieduser='no'") or die(mysql_error()); // get inactive projects where the user has not been mailed.
while($r = mysql_fetch_array($get_inactive_users)) { // sort the users gathered from projects query into an array
$users[] = $r['user'];
$project[] = $r['name'];
}
foreach($users as $value) { // for each user
$get_mail = mysql_query("SELECT * FROM users WHERE username='$value'") or die(mysql_error());
while($r2 = mysql_fetch_array($get_mail)) { //sort the users from the users query into an array
$mail_addy = $r2['email'];
echo $mail_addy;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: NeedSite.net <mailer@needsite.net>' . "\r\n";
$message = "<html>
<style type=\"text/css\">
.form {
background-color:#F2F2F2;
border-bottom-color:#999999;
border-bottom-style:solid;
border-bottom-width:1;
border-top-color:#999999;
border-top-style:solid;
border-top-width:1;
border-left-color:#999999;
border-left-style:solid;
border-left-width:1;
border-right-color:#999999;
border-right-style:solid;
border-right-width:1;
background-repeat:no-repeat;
}
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
}
.style3 {font-size: 14}
.style4 {font-size: 14px}
.style5 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style6 {
font-size: xx-small;
font-family: Geneva, Arial, Helvetica, sans-serif;
}
.style7 {color: #666666}
.style8 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #666666; }
.style9 {color: #9E0309}
.style12 {font-size: 9px; color: #666666;}
</style>
<table width=\"596\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\">
<tr background=\"http://www.needsite.net/img/banner.gif\">
<td valign=\"top\" background=\"http://www.needsite.net/img/banner.gif\" class=\"form\"><div align=\"right\" class=\"style1\"><br>
<span class=\"style3\"><br>
<span class=\"style4\"><strong> Automated email service </strong></span></span><span class=\"style4\"><strong> </strong></span><strong> </strong></div> <p><br>
<br><br>
<span class=\"style8\">Dear $value,<br>
<br>
Our records indicate your project has just ended at <span class=\"style5\"><span class=\"style7\"><a href=\"http://www.needsite.net\" style=\"color:#9E0309\">[url]www.needsite.net[/url]</a></span></span>. Once you've logged in you'll be able to review the bids.</span></p>
<p class=\"style5\"><span class=\"style7\">Regards,<br>
Richard Tagger,<br>
Administrator,<br>
<a href=\"http://www.needsite.net\" style=\"color:#9E0309\">[url]www.needsite.net[/url]</a></span></p></td>
</tr>
</table>
<div align=\"center\" class=\"style6\"> <span class=\"style12\">Copyright NeedSite© 2005<br>
<br>
</span>
<table width=\"596\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\">
<tr>
<td valign=\"top\" class=\"form\"><div class=\"style6 style7\">
<p align=\"center\">Sposored Advertisements:<br>
<br>
<a href=\"http://www.needsite.net/advert.php\" class=\"style9\">Want to advertise here?</a><br>
</p>
</div>
</td>
</tr>
</table>
<span class=\"style12\"> </span></div>
</html>";
mail($mail_addy, 'Project End Notifiation', "$message", $headers);
$make_inactive = mysql_query("UPDATE projects SET notifieduser='yes' WHERE user='$value'") or die(mysql_error());// record the sending.
}
}
?>
that code , where i can send the project title in the mail, so far the project titles are stored in an array.. i ned to include some kind of for each but i need it so that i dont have loops within loops... i needto use to values from two different arrays.. and only send the mail once.any ideas? thanx