Forum Moderators: coopster

Message Too Old, No Replies

Email content help

         

bodycount

2:44 pm on Jun 3, 2008 (gmt 0)

10+ Year Member



I have the basic email working but the content I want is not getting emailed like I want it to. Please see the following code below and comments within the code.

<?php

include ("connection.php");

$RMA = 'RMAC110';

$query15 = "SELECT * FROM `rmatable` WHERE `RMA` = '$RMA' ORDER BY SERIALNO ASC LIMIT 200";

$result15 = mysql_query($query15);

while ($record = mysql_fetch_array($result15))
{
$id = $record["id"];
$COMPANY_id = $record["COMPANY_id"];
$DATERECEIVED = $record["DATERECEIVED"];
$DATERETURNED = $record["DATERETURNED"];
$STATUS = $record["STATUS"];
$COMTECHMODULE = $record["COMTECHMODULE"];
$SERIALNO = $record["SERIALNO"];
$WARR = $record["WARR"];

/************************************************************************
/*
/* This bit works fine and displays all the rows
/*
/************************************************************************/

echo "<td Class=TableRow1>$SERIALNO</td><td Class=TableRow1>$COMTECHMODULE</td><td Class=TableRow1>$DATERECEIVED</td><td Class=TableRow1>$DATERETURNED</td><td Class=TableRow1>$STATUS</td><td Class=TableRow1>$WARR</td><td Class=TableRow1><div id=\"footer\"><div id=\"navfooter\"><ul id=\"navlist\"><li><a href=\"returnnote.php?row_ID=$id\">Returns Note</a></li></li></ul></td><td Class=TableRow1><div id=\"footer\"><div id=\"navfooter\"><ul id=\"navlist\"><li><a href=\"rmaupdate.php?row_ID=$id\">Update</a></li></li></ul></td></tr>";

/************************************************************************
/* This bit below is the email message I want to sent but it is
/* only sending the last row which is got from the database is there
/* away I can get all the rows above to be emailed in one email?
/************************************************************************/

$message1 = "Serial No\t Comtech Module\t Date Received\t Date Returned\t Status\t\t Warranty\r$record[SERIALNO]\t $record[COMTECHMODULE]\t $record[DATERECEIVED]\t $record[DATERETURNED]\t $record[STATUS]\t $record[WARR]\r\r";

}

$to = '********@********.com';

$headers = 'From: ********@********.com' . "\r\n" .
'Reply-To: ********@********.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$message = $message1;
$subject = "$RMA $row_ID from $row[0]";
mail($to, $subject, $message, $headers);

?>

Thanks

Rob.

eelixduppy

2:48 pm on Jun 3, 2008 (gmt 0)



Initialize the $message variable before the loop, and then concatenate all of the rows into the message variable. It would look something like the following:

$message1 = '';
while ($record = mysql_fetch_array($result15))
{
## notice the use of .= instead of just =
## this is for concatenation instead of just assignment
## because of this, we must initialize the var to an empty string
$message1 .= "Serial No\t Comtech Module\t Date Received\t Date Returned\t Status\t\t Warranty\r$record[SERIALNO]\t $record[COMTECHMODULE]\t $record[DATERECEIVED]\t $record[DATERETURNED]\t $record[STATUS]\t $record[WARR]\r\r";
}

Try that and see if it helps you.

bodycount

3:10 pm on Jun 3, 2008 (gmt 0)

10+ Year Member



Thanks for the quick reply, and thanks that worked fine. Don't you just like the quick and simple ones.