Hi,
Ive created a shopping cart using php sessions. The only problem Ive got now, is how to send the cart to a email address. The way its set up at the moment, it sends a email for each line in the cart, not all in one email.
This is the bit of the code:
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
$subtotal = $_SESSION['cart'][$row['id']]['quantity'] * $row['cost'];
$total += $subtotal;
echo " <tr>
<td align=\"left\">{$row['id']}</td>
<td align=\"left\">{$row['name']}</td>
<td align=\"left\">{$row['amount']}</td>
<td align=\"right\">£{$row['cost']}</td>
<td align=\"center\"><input type=\"text\" size=\"3\" name=\"qty[{$row['id']}]\" value=\"{$_SESSION['cart'][$row['id']]['quantity']}\" /></td>
<td align=\"right\">£" . number_format ($subtotal, 2) . "</td>
</tr>\n";
$ses = $_SESSION['cart'][$row['id']]['quantity'];
$cartt = (int) 0;
for ($i = 0; $i < count ($_SESSION['cart']); $i++) {
$cartt = $cartt + $_SESSION['cart'][$i]['quantity'];
$ctotal = $cartt + $ses;
$p =(ceil($ctotal / 12))*9;
$t = $total + $p;
$to = "info@blah.com";
$subject = "New Order";
$message = $row['id'];
}
$emailmessage = "Product name: ". $message . " Quantity: ". $ses ."<br />";
echo $emailmessage;
mail($to,"Order",$emailmessage,"order@blah.com");
So for example, say Ive got 3 different products in the cart, the code above will send a email for each product in the cart, not all in one email which I want it to do.
Any advice or code I could use to solve this problem would be greatly appriciated.
Scott.