December 7th, 2012, 06:07 AM
-
Echo tables
Hi there
I'm working on a feedback form that sends a copy of the content to the sender. In the email it lists the following and prints it out. How would i take the following information and lay it out into a table using the echo command?
PHP Code:
$message = 'Name: '.$name.'
Email: '.$mailFrom.'
Telephone: '.$telephone.'
Address: '.$address.'
Message: '.$message_text;
Thanks
Hudbarnett
December 7th, 2012, 06:57 AM
-
If the objective is to put a table in an email, you wouldn't echo anything. You need to build the email using something like PHPMailer.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
December 7th, 2012, 07:02 AM
-
Originally Posted by gw1500se
If the objective is to put a table in an email, you wouldn't echo anything. You need to build the email using something like
PHPMailer.
Ah, i thought that by placing a table around the code would display it in a table format in the email. I have seen some example on how to do this but so far I've had no luck and haven't been able to get it working.
Thanks for your reply.
Hudbarnett
December 7th, 2012, 08:05 AM
-
Originally Posted by hudbarnett
How would i take the following information and lay it out into a table using the echo command?
Exactly the same as if you were building it for a webpage but instead of echo, use variable concatenation,
eg
PHP Code:
//
echo "<table>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "</table>";
becomes
PHP Code:
//
$output.="<table>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="</table>";
if you're going from existing source code to new, do a find and replace for "echo" and replace with "$output.=" (without quotes
)
Then, use a library like PHPMailer (see gw1500se's post) to build and send an HTML email (using the html that's in your $output variable);
If you really really really wanted to use echo then you'd want to wrap output buffers around the relevant echo statements and then collect the contents into a variable which you would then pass into PHPMailer to send an html email
December 7th, 2012, 08:40 AM
-
Originally Posted by Northie
Exactly the same as if you were building it for a webpage but instead of echo, use variable concatenation,
eg
PHP Code:
//
echo "<table>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "<tr><td>....</td><td>....</td></tr>";
echo "</table>";
becomes
PHP Code:
//
$output.="<table>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="<tr><td>....</td><td>....</td></tr>";
$output.="</table>";
if you're going from existing source code to new, do a find and replace for "echo" and replace with "$output.=" (without quotes

)
Then, use a library like PHPMailer (see gw1500se's post) to build and send an HTML email (using the html that's in your $output variable);
If you really really really wanted to use echo then you'd want to wrap output buffers around the relevant echo statements and then collect the contents into a variable which you would then pass into PHPMailer to send an html email
Hi there
Thank you for pointing me in the right direction, i'm going to give it a go and see how i get on.
Thank you
Hudbarnett