The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - Echo tables
Discuss Echo tables in the PHP Development forum on Dev Shed. Echo tables PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 7th, 2012, 06:07 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Location: Edinburgh
Posts: 19
Time spent in forums: 3 h 19 m
Reputation Power: 0
|
|
|
PHP-General - 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
|
|
Registered User
|
|
Join Date: Nov 2012
Location: Edinburgh
Posts: 19
Time spent in forums: 3 h 19 m
Reputation Power: 0
|
|
Quote: | 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
|
 |
Square Peg in a Round Hole
|
|
Join Date: Oct 2007
Location: North Yorkshire, UK
|
|
Quote: | 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
|
|
Registered User
|
|
Join Date: Nov 2012
Location: Edinburgh
Posts: 19
Time spent in forums: 3 h 19 m
Reputation Power: 0
|
|
Quote: | 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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|