how to echo 2 classes

This is a discussion on "how to echo 2 classes" within the PHP Forum section. This forum, and the thread "how to echo 2 classes are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 9th, 2007, 13:20
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 19
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to geyids Send a message via Yahoo to geyids Send a message via Skype™ to geyids
how to echo 2 classes

Hi Forumz
I have to values that I want to be applied on the same li link. I have

Code: Select all
$sw = 'class="now"';
and
class="final"
I want to echo the php and put the htmll too. When I try this,
Code: Select all
<li><a href="contact/" title="Contact Us" <?php echo $sw; ?> class="now">Contact Us</a></li>
The results are only the php <?php echo $sw; ?> appears and when I do vice versa the one which appears first is the one considered.

Heeeelp please.

Regards Jon
Reply With Quote

  #2 (permalink)  
Old Aug 9th, 2007, 13:27
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how to echo 2 classes

Your $sw variable should contain "now" only

PHP: Select all

$sw "now"
And then you can apply multiple class name to the element like so

HTML: Select all
<li><a href="contact/" title="Contact Us" class="final <?php echo $sw; ?>">Contact Us</a></li>

Last edited by karinne; Aug 9th, 2007 at 13:51. Reason: Added the " quotes ;)
Reply With Quote
  #3 (permalink)  
Old Aug 9th, 2007, 13:45
Junior Member
Join Date: Aug 2007
Location: London
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Re: how to echo 2 classes

But don't forget the closing double quote for the class attribute.

Try the following:

Code: Select all
<li><a href="contact/" title="Contact Us" class="final <?=$sw?>">Contact Us</a></li>
Reply With Quote
  #4 (permalink)  
Old Aug 9th, 2007, 13:47
Reputable Member
Join Date: Mar 2007
Location: Kenya
Age: 19
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to geyids Send a message via Yahoo to geyids Send a message via Skype™ to geyids
Re: how to echo 2 classes

thanks I have closed the " after ?> so its like this. It works as I wanted. Thanks

Code: Select all
<li>
Code: Select all
<a href="contact/" title="Contact Us" class="final <?php echo $sw; ?>">Contact Us</a></li>


and
Code: Select all
$sw = 'now'

Last edited by geyids; Aug 9th, 2007 at 13:50.
Reply With Quote
Reply

Tags
class

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
echo proxy to csv stiassny JavaScript Forum 1 Apr 13th, 2008 16:51
How do I echo <?php ..... AdRock PHP Forum 12 Sep 14th, 2007 13:20
Echo and If simonb PHP Forum 2 Aug 27th, 2007 16:22
Echo and Sessions kool77 PHP Forum 6 Jun 1st, 2007 22:32
Echo vs Print Sqrlgrl PHP Forum 3 May 30th, 2005 22:31


All times are GMT. The time now is 02:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43