can i send function output data to mail?
I have 2 functions and I want to send all functions data to my mail I tried like this these are my functions
function cart1();
function cart2();
my function codes
<开发者_如何学编程;?php
function cart1 () {
foreach($_SESSION as $name => $value){
if ($value>0) {
if (substr($name, 0, 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>
I just want to know how to convert function's output into form object. can any 1 help me.
<?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 (); ?>">
精彩评论