如何解决我可以将功能输出数据发送到邮件吗?
| 我有2个功能,我想将所有功能数据发送到我的邮件中 我尝试过这样 这些是我的职能function cart1();
function cart2();
我的功能代码
<?php
function cart1 () {
foreach($_SESSION as $name => $value){
if ($value>0) {
if (substr($name,5)==\'cart_\') {
$id = substr($name,5,(strlen($name)-5));
$get = mysql_query(\'SELECT id,name,price FROM products WHERE id=\'.mysql_real_escape_string((int)$id));
while ($get_row = mysql_fetch_assoc($get)) {
$sub = $get_row[\'price\']*$value;
echo $get_row[\'name\'].\' x \'.$value.\' @ £\'.number_format($get_row[\'price\'],2).\' = £\'.number_format($sub,2).\'<a href=\"cart.php?remove=\'.$id.\'\">[-]</a> <a href=\"cart.php?add=\'.$id.\'\">[+]</a> <a href=\"cart.php?delete=\'.$id.\'\">[Delete]</a><br />\';
}
}
}
}
}
?>
<form action=\"email.php\" method=\"post\">
<input type=\"hidden\" name=\"cart1\" value=\"<?php cart1 (); ?>\">
<input type=\"hidden\" name=\"cart2\" value=\"<?php cart2 (); ?>\">
<input type=\"submit\" name=\"submit\" value=\"Submit\" >
</form>
我只想知道如何将函数的输出转换为表单对象。谁能帮我一个忙。
解决方法
<?php
function cart1() {
$results = \'\';
foreach(...) {
...
$results .= $get_row[\'name\'].\' x \'.$value.\' @ £\'.number_format($get_row[\'price\'],2).\' = £\'.number_format($sub,2).\'<a href=\"cart.php?remove=\'.$id.\'\">[-]</a> <a href=\"cart.php?add=\'.$id.\'\">[+]</a> <a href=\"cart.php?delete=\'.$id.\'\">[Delete]</a><br />\';
}
return $results;
}
?>
<input type=\"hidden\" name=\"cart1\" value=\"<?php echo cart1 (); ?>\">
<input type=\"hidden\" name=\"cart2\" value=\"<?php echo cart2 (); ?>\">
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。