Can you use html/css in an echo or print command?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmandango
Forum Newbie
Posts: 19
Joined: Wed Jun 05, 2002 10:39 am
Location: Michigan

Can you use html/css in an echo or print command?

Post by jmandango »

This is what I have right now:

Code: Select all

echo "Thank you! Information entered.\n";
I want to be able to apply a css style to this and/or some html stuff (ie. <table cellpadding="3"><tr><td class="sumptin">Thank you! Information entered.</td></tr></table> )

thank you for your help!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Code: Select all

echo '<table cellpadding="3"><tr><td class="sumptin">Thank you! Information entered.</td></tr></table>';
jmandango
Forum Newbie
Posts: 19
Joined: Wed Jun 05, 2002 10:39 am
Location: Michigan

echo in an echo?

Post by jmandango »

Sweet that worked. But now, how do I put an echo in an echo?

Here's what I mean:

Code: Select all

echo '<table align="center" cellpadding="3"><tr><td align="center" class="graybold">Thank &#1111;color=#FF0000]&#1111;b]"$first_name"&#1111;/b]&#1111;/color] you for voting!</td></tr></table>';
I want to put the user's name in the above area captured from a form field on the page. Can you put an echo in an echo?
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

This should work:

echo '<table align="center" cellpadding="3"><tr><td align="center" class="graybold">Thank you "$_POST[first_name]" for voting!</td></tr></table>';
jmandango
Forum Newbie
Posts: 19
Joined: Wed Jun 05, 2002 10:39 am
Location: Michigan

hmmm, didn't work

Post by jmandango »

I tried that, $_POST, but it didn't work?

any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

PHP ignores stuff in strings contained in single quotes so you need something like:

Code: Select all

echo '<table align="center" cellpadding="3"><tr><td align="center" class="graybold">Thank you '.$_POST&#1111;'first_name'].' for voting!</td></tr></table>';
Mac
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

and make sure the form is sent using post :-P
jmandango
Forum Newbie
Posts: 19
Joined: Wed Jun 05, 2002 10:39 am
Location: Michigan

thanks

Post by jmandango »

Thank you, the single quote worked. Yee-Haaa!!!!
Post Reply