Log in

View Full Version : Show last comment script



careera
11-03-2006, 03:13 PM
Hi guys,

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

Can anybody help with this :confused: ! I would be greatful.

Thanks

djr33
11-04-2006, 06:11 AM
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.

careera
11-04-2006, 08:40 AM
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

mburt
11-05-2006, 04:00 PM
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.



$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.

djr33
11-06-2006, 08:04 AM
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.