Remortgaging - Xbox Mod Chip - Debt Help - Remortgages - Adverse Credit Remortgage

PDA

View Full Version : Some help with mysql_query - Screen output works, mail() not


HolyMan
Sep 17th 2004, 7:34 am
Hi All,

Having a small problem with inputing some info into the php mail() function.

What I have at the moment is
$edquery = "SELECT institute,
degree,
subject,
year
from jobs_r_education,
jobs_degree,
jobs_subject
WHERE jobs_r_education.fk_degree = jobs_degree.id
AND jobs_r_education.fk_subject = jobs_subject.id
AND rid = '$rid'
ORDER BY year";
$result = mysql_db_query($database, $edquery, $connection) or die ("Error in query: $edquery. " . mysql_error());
if(mysql_num_rows($result) > 0){
while (list($institute, $degree, $subject, $year ) = mysql_fetch_row($result)){
$education = "Institute: $institute,<ul>Degree: $degree,<br>Subject: $subject,<br>Year Completed: $year</ul>";
echo "$education";
}
}

This works like a bomb and the "echo "$education"; " outputs all returned responses to the screen perfectly

However, when $education is included in the message part of mail(), only the last record is inserted into the mail.

Any help greatly appreciated.......

PS....my php knowledge is relatively light, so please be gentle


Cheers

rvarcher
Sep 17th 2004, 8:25 am
You're not building upon $education.

You're setting it anew each time.

Try $education .=

That will deliver what you want.

echo looks OK because you're outputting each result but not correctly assigning the results to $education.

http://www.php.net/manual/en/language.operators.assignment.php
php.net is your friend.

- Bob Archer
http://www.tropicrentals.com - Vacation Rentals Online.

HolyMan
Sep 20th 2004, 1:08 am
Brilliant..... Thanks

Works well for the mail() function.......