runnerjp
05-30-2008, 01:59 PM
how would i display <?php if($important == 1){ class='mainrow1' } else {class='mainrow2} ?> correctly... im not sure how to use classes within php ... or can it even be done?
|
||||
<?php if($important == 1){ class='mainrow1' } else {class='mainrow2} ?>runnerjp 05-30-2008, 01:59 PM how would i display <?php if($important == 1){ class='mainrow1' } else {class='mainrow2} ?> correctly... im not sure how to use classes within php ... or can it even be done? derzok 05-30-2008, 02:20 PM Classes as in html? Or classes as in object oriented php programming? I think you'll have to show us more code than that... Also, you didn't close the quotes on mainrow2. runnerjp 05-30-2008, 02:31 PM basicly what i want to do is <?php if($important == 1){ class='mainrow1' } else {class='mainrow'} ?> so if my forum area is important make it red if not make it blue for example so if important == 1 do this .mainrow1 {font-family: Verdana,Sans-serif;color: #000000;background-color: #eeeeee;font-size: 12px; a:link, a:visited, a:active { text-decoration: none}} /*color of the forum rows*/ else do this .mainrow {font-family: Verdana,Sans-serif;color: #000000;background-color: #F2F2F2;font-size: 12px; a:link, a:visited, a:active { text-decoration: none}} /*color of the forum rows*/ derzok 05-30-2008, 02:39 PM if($important==1) { $class = "mainrow1"; } else { $class = "mainrow2"; } Then when you're displaying the html element that's changing color: echo '<tag class="' . $class . '">Tag content</tag>'; Similar code produces this: http://zb3.zoklet.net/globalstats.php // inside the loop that echoes the alternating colored rows $switch = 0; if($switch % 2 == 0){ echo "<tr align=\"center\" class=\"rowa\">\n"; } else { echo "<tr align=\"center\" class=\"rowb\">\n"; } // echo row's contents here // and here echo '</tr>'; $switch++; runnerjp 05-30-2008, 02:45 PM ahhh yes didnt think of doing it that way! ty :) |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum