2013-03-08 115 views
0
$content="<table width='200' border='0'> 
    <tr> 
    <td>product name</td> 
    <td>Price</td> 
    <td>Qty</td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
</table>" 

上表是邮件的内容。添加动态行到邮件内容

$pdtname , $price and $qty包含产品名称,产品价格和产品数量。

[email protected]("[email protected]",$sub,$content,$headers); 

如果用户选择一个或多个产品

是否有可能根据所选择的产品的数量乘以$content内的表的第二行。

回答

1

试试这个:

$content = "<table width='200' border='0'> 
    <tr> 
    <td>product name</td> 
    <td>Price</td> 
    <td>Qty</td> 
    </tr>"; 
foreach($products as $product){ 
    $content .= " <tr> 
    <td>".$product['name']."</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr>"; 
} 
$content .= "</table>"; 
+0

谢谢..它工作得很好.... – Anoop 2013-03-08 15:45:34

0

使用foreach循环这样

$content = "<table width='200' border='0'> 
<tr> 
    <td>product name</td> 
    <td>Price</td> 
    <td>Qty</td> 
</tr>"; 
foreach($rows as $row){ 
    $content .= " <tr> 
    <td><?php echo $row['product_name'];?></td> 
    <td><?php echo $row['product_price'];?></td> 
    <td><?php echo $row['product_quantity'];?></td> 
    </tr>"; 
} 
$content .= "</table>"; 
+0

Ofcourse这将增加产品的名称,价格,数量也...对..?? – Gautam3164 2013-03-08 12:28:12

+0

任何人都可以告诉我这里列出的更好的ans .. ?? – Gautam3164 2013-03-08 12:45:19