Jump to content

Recommended Posts

Why do i always get more code right when im about to goto bed 0.o Right got the news page 100% working now with bbcode, and authors name taking you to the persons profile. All i need now is to make it so that when a new comment is made the colour of the link changes. So say the link says Comments|0 in blue it go Comments|1 in green?

 

Also is there a way to make new comments be another color from the rest? By that i mean the bg color of the table the comment is in.

 

What code do you require to help with this if you help that is :P

 

One last thing... how the heck do i add error fields like the one on this forum (i posted with no subject and the post was still here and i was told what was wrong! on mine it goes "Missing Imput" and i loose all the post :'(

Link to comment
https://forums.phpfreaks.com/topic/112026-change-color-on-new-post/
Share on other sites

1) in your loop that displays it, you just use a variable that acts like a switch. Something as simple as this will work:

$x = 0;
while/for(....) {
  $color = (($x % 2) == 0)? "#0000FF" : "#00FF00";
  $x++;
  // your stuff to display here: use $color as the color
}

 

2) The short answer is yes.  The long answer depends on what you mean by "new comments". Do you mean x amount of newest comments, based on straight last x posts, or all within x time? Do you mean just the very last comment posted? Regardless, your condition would also be inside your loop that displays them.

 

3) use 1 and 2 to try and work it out. if you're having issues, post what you've tried

 

4) on your form validation you're checking posted vars right? and if something is missing/wrong, you spit out an error message and display the form again right? If the form is on the same page as the validation, simply use the posted vars as default values in your form elements.  On page load, they will either be blank (because first time coming) or filled out with what you had (because you submitted).  If it is on a different page, you can use session vars instead.

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.