0

hello everyone,

i think this a rather complex question but i'll have a go.

i have this output from mysql printed on a php page:

user1
-------------------
week | hours worked | hours had to work | missing hours
32 | 30 | 32 | 2

user2
-------------------
week | hours worked | hours had to work | missing hours
32 | 30 | 32 | 2


and so on.

now that i want is to send an email to the user telling them in what week the missed how many hours.

here is my code sofar:

//mysql stuff

while($row = mysql_fetch_assoc($sql)){

$a = $row['workingtime'];
$b = $row['workedtime'];

     if ($a < $b)
        {
     if($row['username'] != $cat) 
     echo "<h3>".$row['username']."".$row['useremail']."</h3>\r\n";
     echo  "<p>working time:".$row['workingtime']."worked time:".$row['workedtime']."Week:".$row['weeknr']."</p>\r\n";
 
$msg = "<h3>".$row['username']."".$row['useremail']."</h3>"."<p>working time:".$row['workedtime']."working time:".$row['workingtime']."Week:".$row['weeknr']."</p>";

$cat = $row['username'];
}
$to = $row['useremail'];
$subject = "reminder";
$body = "" . $msg . "";
$headers  = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From: <reminderservice@reminderservice.com>' . "\n";

mail($to, $subject, $body, $headers);

this even sort of works, the only thing i want is to send the user his/her overview of weeks with hours missing.
Now the script is sending an email for every week where hours are missing.

any help is greatly appreciated!

4
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by pietpiraat
0

Just to understand, this will be for all weeks or in a certain time frame? What is the output that your getting right now?

0

Yes in my query i call

date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)

and i am able to print this onscreen :
user1
-------------------
week | hours worked | hours had to work | missing hours
32 | 30 | 32 | 2
33 | 29 | 32 | 3
34 | 20 | 32 | 12

user2
-------------------
week | hours worked | hours had to work | missing hours
32 | 30 | 32 | 2


Now the email even sends but like this:

user1
-------------------
week | hours worked | hours had to work | missing hours
32 | 30 | 32 | 2

so every user gets his email per week and i want them to receive an overview of their weeks in one email.

thanks for helping sofar

0

anyone have a pointer for me?

Edited by pietpiraat: n/a

0

excuse my explanation, the problem is this:
in my while loop i check if users have filled out their hours for past week.
if they didnt work the hours they should have i print it on my screen, this is for the admin only.

i want the user to receive an email with their missing hours per week.

what i managed to do is send an email to the users, but it sends an email per week, and i want it to mail an overview of all weeks where they didnt meet their hour criteria, just like it gets printed onscreen.

thanks for helping

0

What is this doing. What do these variables do mean?

$a = $row['workingtime'];
$b = $row['workedtime'];

1. You send email, regardless of whether If condition is true or false.
2. While loop isn't closed ('}')

Edited by Stefano Mtangoo: n/a

0

Thanks,

i havent been able to check the code, will post back soon thanks for helping sofar!

0

Well , i suggest instead of writing the code to the screen, take a look at the Output buffer (ob_start,ob_clean_end) functions of php...This way you can put all your content in one variable, and then just send the email with the content of this var.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.