Forum Moderators: coopster
mysql_select_db("keurslager");
$result = mysql_query("SELECT * FROM orders WHERE sessionid = '$id' ");
if(!$result)error_message(sql_error());
for($i = mysql_num_rows($result)-1; $i >=0; $i--)
{
$bestelling = "<TR>",
"<TD>", mysql_result($result, $i, "aantal"),"</TD>",
"<TD>",mysql_result($result, $i, "productomschrijving"), "</TD>",
"<TD>",mysql_result($result, $i, "Boter"), "</TD>",
"<TD>",mysql_result($result, $i, "Extra"), "</TD>",
"<TD>",mysql_result($result, $i, "Opmerkingen"), "</TD>",
"<TD>€ ",mysql_result($result, $i, "Prijs"),",-", "</TD>";
}
$aanhef = "Uw bestelling is bevestigd!<BR>";
$afsluiting = "Met vriendelijke groet BON Keurslager";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Bcc: $email\r\n";
$subject = "Bevestiging bestelling";
$message = "$aanhef $bestelling $afsluiting";
Someone has a hint thanks
A couple of things. First, you are resetting the variable on every iteration of the loop to the current loops result set data. You may want to initialize it before you enter the loop, then concatenate to it on every iteration. Second, I believe you also want to concatenate the pieces within the loop using the concatentation operator which is a period, not a comma:
$bestelling = ''; // initialize
for($i = mysql_num_rows($result)-1; $i >=0; $i--)
{
$bestelling .= "<TR>".
"<TD>".mysql_result($result, $i, "aantal")."</TD>".
"<TD>".mysql_result($result, $i, "productomschrijving"). "</TD>".
"<TD>".mysql_result($result, $i, "Boter"). "</TD>".
"<TD>".mysql_result($result, $i, "Extra"). "</TD>".
"<TD>".mysql_result($result, $i, "Opmerkingen"). "</TD>".
"<TD>€ ".mysql_result($result, $i, "Prijs").",-". "</TD>";
}