Results 1 to 5 of 5

Thread: Show last comment script

  1. #1
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Show last comment script

    Hi guys,

    I'm looking for a script that would display X number of last comments of an article.

    Can anybody help with this ! I would be greatful.

    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This is VERY dependant on how the comments are stored.
    Please explain.
    Also, what, exactly, does "last" mean? There are a few meanings with something this precise.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hi

    Thanks for replying

    See.. visitors come and add comments to the articles and what i want is to show/display the last 10 comments for example on the home webpage.

    I know it is possbile and i've seen it in so many webpages (even on some forums where it is displayed in the hor bars cross the page) but i'm sooo poor in programing and it would be great if i can find a tool/script.

    Cheers

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    What method are you using to add comments to the article? How could you define the different comments?

    If you stored comments in a file like this

    comment 1 | comment 2 | comment 3
    etc.

    you could split them by "|", and group by the last ten comments.

    Code:
    $file = file_get_contents("file.txt");
    $mix = explode("|", $file);
    $num = 10;
    if (count($mix) < 10) {
    	$num = count($mix) + 1;
    	}
    else {
    	$num = 10;
    	}
    for ($i = count($mix);$i > count($mix) - $num;$i--) {
    	echo "$mix[$i]<hr>";
    	}
    Untested

    That's the only solution I can think of.
    Last edited by mburt; 11-05-2006 at 04:20 PM.
    - Mike

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    We don't know how they're stored. Exactly.
    That's what I meant above.
    I know you wnat to display the last X number of them, but we can't give you a code without knowing how to access them.

    Basically.... just get the data and limit it to 10. That's the answer in general, but to make it work, it would need to be specified for a particular setup.

    The above setup, for example, is for a .txt file or something similar. using a database, there are other methods, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •