programguru Posted March 24, 2010 Share Posted March 24, 2010 I am simply trying to store the full results of my while loop in a variable to store into a variable for a mail() script I am writing. while(list($key, $val) = each($_POST)) { "<strong>$key</strong> => $val<br />"; } $message = $while_full_result; echo $message; This should echo the same output as the while loop natively does. But I cannot get this to work properly. Thanks for any advice. Quote Link to comment Share on other sites More sharing options...
o3d Posted March 24, 2010 Share Posted March 24, 2010 $while_full_result=''; while(list($key, $val) = each($_POST)) { $while_full_result .= "<strong>$key</strong> => $val<br />"; } Quote Link to comment Share on other sites More sharing options...
programguru Posted March 24, 2010 Author Share Posted March 24, 2010 o3d, Thanks. Worked like a charm. I guess I have a lot to learn with this specific type of loop, because I can't get this to work with my table output structure now. It's only echoing the key value pair from the form: $while_full_result=''; while(list($key, $val) = each($_POST)) { $while_full_result = "<table border=\"1\">"; $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>"; $while_full_result .= "</table>"; } $message = $while_full_result; Quote Link to comment Share on other sites More sharing options...
programguru Posted March 24, 2010 Author Share Posted March 24, 2010 o3d, Thanks. Worked like a charm. I guess I have a lot to learn with this specific type of loop, because I can't get this to work with my table output structure now. It's only echoing the key value pair from the form: $while_full_result=''; while(list($key, $val) = each($_POST)) { $while_full_result = "<table border=\"1\">"; $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>"; $while_full_result .= "</table>"; } $message = $while_full_result; I actually had luck echoing it to the page, but I could not get it to print in the email????? $while_full_result=''; while(list($key, $val) = each($_POST)) { $while_full_result .= "<tr><td>$key</td><td>$val</td></tr>"; } $message = "<table>$while_full_result</table>"; echo $message; // Mail it mail($to, $subject, $message, $headers); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.