runnerjp Posted May 30, 2008 Share Posted May 30, 2008 hey guys i wanna chnage the background of the table with an if statement like so <tr <?php if($important == 1){bgcolor='#993399'} else {bgcolor='#F2F2F2'} ?> class='mainrow'><td width="3%"> but it does not seem to work .. Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted May 30, 2008 Share Posted May 30, 2008 try... <tr <?php if($important == 1){ echo "bgcolor='#993399'"; } else { echo "bgcolor='#F2F2F2'"; } ?> class='mainrow'><td width="3%"> that should definately work Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 humm my $imprtant is not working...can you see where its going wrong?? $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY lastrepliedto DESC $max"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $important=$getthreads3[important] ?> <tr <?php if($important == 1){ echo "bgcolor='#993399'"; } else { echo "bgcolor='#F2F2F2'"; } ?>class='mainrow'><td width="3%"><? if($getthreads3[author] == $puser){ ?> <img src="http://www.runningprofiles.com/images/my folder.gif" alt="My" /> <?} else { echo 'nooo'; } ?> Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted May 30, 2008 Share Posted May 30, 2008 instead of... $important=$getthreads3[important] try using... $important=$getthreads3['important']; As you can see i aded a semi colon to the end of the variable and also added those small quotes around important Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 saldy that did not work in chnaging the colour buti can echo the no 0 or 1! <?php $getthreads="Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY lastrepliedto DESC $max"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=mysql_fetch_array($getthreads2)) { $getthreads3[title]=strip_tags($getthreads3[title]); $getthreads3[author]=strip_tags($getthreads3[author]); $getthreads3[important]=strip_tags($getthreads3[important]); $important=$getthreads3['important']; ?> <tr <?php if($important == 1){ echo "bgcolor='#993399'"; } else { echo "bgcolor='#F2F2F2'"; } ?>class='mainrow'><td width="3%"><? if($getthreads3[author] == $puser){ ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 i was thinkin of doing something like this instead <?php if($important == 1){ class='mainrow1' } else {class='mainrow2} ?> how wouldi do this correctly Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 30, 2008 Share Posted May 30, 2008 if($important == 1){ class='mainrow1' } else if($important==2) {class='mainrow2} Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 with <?php if($important == 1){ class='mainrow1' } else if($important == 2) {class='mainrow2}?> i get unexpected =expecting t_sting Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 30, 2008 Share Posted May 30, 2008 if($important == 1){ class='mainrow1' } else if($important==0) {class='mainrow2} Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 i think its how class='mainrow1' is done Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted May 30, 2008 Share Posted May 30, 2008 shouldnt ie be a variable like $class ??? Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 huh what u mean,,, class is css Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted May 30, 2008 Share Posted May 30, 2008 your ,meant to be echoing the class Quote Link to comment Share on other sites More sharing options...
runnerjp Posted May 30, 2008 Author Share Posted May 30, 2008 if($important==1) { $class = "mainrow1"; } else { $class = "mainrow2"; } then <tag class="' . $class . '"> did it wahoo Quote Link to comment Share on other sites More sharing options...
Sulman Posted May 30, 2008 Share Posted May 30, 2008 You need to echo the class <?php <tr class="<?php if($important == 1){ echo "mainrow1"; } else { echo "mainrow2"; } ?>"><td width="3%"> ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.