Forum Moderators: coopster

Message Too Old, No Replies

Quick help

mail php

         

ikke

2:23 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



This is a small piece of code of a whole ecommerce system I want to mail All the products the the client but the variable $bestelling does not work. The $bestelling must be the product list. Is this the right to make a product list in a mail way? what do I do wrong?


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

coopster

3:24 pm on Mar 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, ikke.

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>";
}

ikke

6:25 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



Thanks for the warm welcome :) and the help

I will try it tommorow. I`ll let you know if it works.

Greet

ikke

6:56 am on Mar 22, 2005 (gmt 0)

10+ Year Member



I Just want to say that it works great.

Thanks