Monkuar Posted March 18, 2012 Share Posted March 18, 2012 $color = ' class="pin"'; $pin++; echo $pin; long story short, let's just say, this is inside a while loop echoing out my forum Topics. $pin echo's out 1 2 3, because they're 3 stickied Topics. I only want class="pin" to display on the very last <tr> tag. (which would be number 3, how?) <tr<?php echo $color ?>> OK i do if ($pin == 4){ $color = ' class="pin"'; } works if I have 4 Topics, stickied, but how would i change 4 to be dynamic? what if only 2 topics stickied? I tried if ($pin == $pin){ $color = ' class="pin"'; } not work.. wouldn't $pin = 4? bcz $pin++ ? my help topics seem so noob, but i just cant comprehend lol Quote Link to comment Share on other sites More sharing options...
trq Posted March 18, 2012 Share Posted March 18, 2012 Surely a pinned topic would have a flag of some sort on it. Why not use that flag to trigger a different css class? Your logic doesn't make a whole lot of sense here. Quote Link to comment Share on other sites More sharing options...
Monkuar Posted March 18, 2012 Author Share Posted March 18, 2012 Surely a pinned topic would have a flag of some sort on it. Why not use that flag to trigger a different css class? Your logic doesn't make a whole lot of sense here. well it does, but im only trying to show that class at the bottom of the last stickied topic, in that tr class, because it shows a "border-bottom" properties so it differentiates between stickied topics and the normal posts, but i just cant figure out how to do it dynamic the if ($pin == 4) works, but cant do it dynamic because if it's a loop then the $pin will be 4 44 444 4444 or w/e i just need to find out how to get my $pin == 4 in the loop dynamically thats all Quote Link to comment Share on other sites More sharing options...
cpd Posted March 18, 2012 Share Posted March 18, 2012 There are a number of ways you could make it dynamic which are dependent on how you go about getting your topics? More code needed. An example could be putting a COUNT function in your SQL query which gets all your topics (Again dependent on whether or not you get all the topics in one query. That would be the most efficient way of doing it). SELECT *, COUNT(pinned) AS `totalPinned` FROM.... You can then test for whether or not $pin is equal to the totalPinned. But this is all dependent on your methods prior to the code you've outlined already. 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.