a way to insert tables into a variable using html,php


#1

I have been trying to format an email message that i was sending useing the mail() function in php but the data is only seperated by a space. is there any way of using html or php to make a table inside a varible which would be the message part of my email


#2

If I understand correctly what you are trying to do, then yes.

You will want to parse through the data. The str_replace(), substr(), and various other string manipulation tools through php should help with this. You might also want to look at the explode() and implode() as they are very helpful in managing data as well.

For more information on any of the function mentioned above look here:
http://www.php.net

You can also do google searches to find various kinds of information on this as well.

HTH,
RAG


#3

thanks ragster,

that would help if i were dealing with only one string but i have many strings which need to be put in the one string to send via mail(). If i could insert a break
between each of the strings that would be perfect is there any way of doing that this is the code i am using

$txt= ‘Email:’ . ’ ’ . $_POST[‘email’] . ’ ’ . .$_POST[‘comments’]

mail($to, $subject, $txt) ;

i would like to insert a line break in the orange area


#4

.’
’.


#5

Thanks

I havn’t tried that because i would need to end the php ?> and enter html mode and im to sure if you can do that. I belive you cant.


#6

No you don’t. You can just enter it as a text string into a variable without ever leaving PHP.


#7

Yes it does work when you print the variable on the screen when you send it via mail() it shows all of the items with a bunch of
in between but it doesn’t skip to the nest line


#8

I’m new to php myself, so I may be off on this, but it seems to me that if you’re not leaving php, inserting the newline code after the
might help. It would look like this:
n


#9

The
should break the line on HTML-level. I’m suspecting your email to show it because your email program does not treat the email as HTML formatted. Not sure if setting the correct meta tag will make a difference, but it’s worth the try. Also, try and see if I can set your email program to display emails in HTML format (rather than plaintext or RTF).