I have a table of members and a table of jobs. The members table contails details such as name, email, jobseeeker( this says 'on' if they want job matches sent to them), and query( this contains a query that was saved from when they initailly selected which jobs that they are interested in , so for examply this could say " SELECT * FROM jobs where 1 and (division='L') and (sector='FU') and (location='0') order by division").
Right i am using the 'query' field to produce a set of results from the jobs table, which i then send to the recipient.
Here is my code
include("../app_global.php");
$display_block = "";
// step 1 get all the my_brightwaters who want job matches sent to them
//open the connection
$conn = mysql_connect("$glob_host", "$glob_user", "$glob_pass");
//pick the database to use
mysql_select_db($db_name, $conn);
// select only those who want the job matches sent to them
$sql = "SELECT *
FROM my_brightwater
WHERE jobseeker = 'on'";
$result = mysql_query($sql,$conn)or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
//give a name to the fields
$fullname = $row['fullname'];
$email=$row['email'];
$query=$row['query'];
//now we have the individual queries from the database we want to build a new query out of it, this
$sql2 = "$query";
$result2 = mysql_query($sql2,$conn)or die(mysql_error());
while ($row2 = mysql_fetch_array($result2)) {
//give a name to the fields
$job_title = $row2['job_title'];
$job_key = $row2['job_key'];
$division=$row2['division'];
$sector=$row2['sector'];
$location = $row2['location'];
$salary = $row2['salary'];
$job_id = $row2['job_id'];
$perm_temp=$row2['perm_temp'];
$company=$row2['company'];
$location=$row2['location'];
$job_title=$row2['job_title'];
$job_notes=$row2['job_notes'];
$display_block .="<table width=\"450\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"top\" class=\"jtitle\">$job_title</td><td>Ref: $job_key</td></tr><tr><td colspan=\"2\">$location</td></tr><tr><td colspan=\"2\">$job_notes</td></tr><tr><td height=\"20\" colspan=\"2\"></td></tr></table>";
}
//mail stuff
$msg = "
Hello $fullname<br>
Your Job Matches are:<br><br>
$display_block
";
//$mailto = "$email";
$from = "postmaster@brightwater.ie";
$subject = "Job Search Results";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: postmaster@brightwater.ie\n";
$headers .="To: $email\n";
mail($from, $subject, $msg, $headers);
$display_block5 .="Job Matches have been sent to $email\n";
//end mail stuff
}
The jobs that match are being sent out fine however only the last recipient in the list is recieving this, how can i tell it to send to all members??
Thanks in advance