Thread: Echo tables

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Edinburgh
    Posts
    19
    Rep Power
    0

    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
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,466
    Rep Power
    594
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Edinburgh
    Posts
    19
    Rep Power
    0
    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
  6. #4
  7. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4123
    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
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Edinburgh
    Posts
    19
    Rep Power
    0
    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

IMN logo majestic logo threadwatch logo seochat tools logo