Phpmailer and list insertion

Hi

I am trying to send an email which contains some data pulled from a mysql set of tables.

There are two tables - applicant and documents linked by a field idcode.
In the documents table there is also a field called doctitle. For one idcode there could be any number of documents.

I am using phpmailer and parts of my code are as follows:

One part gets the idcode from the url:

if(isset($_GET[‘idcode’])){
$idcodepassed = $_GET[‘idcode’];
}else{
$idcodepassed = 111111; // set this to your default value if no URL value is present
}

There is a section to get the data from the tables using this idcode:

mysql_select_db($database_process, $process);
$result = mysql_query("SELECT applicant.applicantid, applicant.idcode, username, password
FROM applicant
WHERE idcode = ‘$idcodepassed’
LIMIT 1
");

while($row = mysql_fetch_array($result))
{
$appid = $row[‘applicantid’];
$idcode = $row[‘idcode’];
$username = $row[‘username’];
$password = $row[‘password’];
}

mysql_select_db($database_process, $process);
$result3 = mysql_query("SELECT doctitle
FROM documents
WHERE documents.idcode = ‘$appidpassed’
");

and then there is the body of the email which I have as:

$body = "<html><body>
<br><br>Some test data:<br><br>
idode = $idcode<br>
appid=$appid<br>
username = $username<br>
password =$password<br>
<p>Kind regards</p><br><br>
</body></html>

";

while($row = mysql_fetch_array($result3))
{
$body .= $row[‘doctitle’].“<br />”;
}
$body .= "<html><body>

and here’s some final text<br><br><br><br>
</body></html>

";

The first and last part are OK but the middle part (which I hoped would list the doctitles with the correct idcode) doesn’t.

I imagine the fix is simple but I’m not sure what it is.

Any suggestions will be very welcome.

WHERE documents.idcode = ‘$appidpassed

uh…didnt set that one anywhere. Think maybe you meant $idcodepassed …

Many thanks. I looked and looked and couldn’t see it. All works fine now.