Jump to content

im stumped rofl


Monkuar

Recommended Posts

$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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.