On 2004-01-20, OllimaX <ollimantyranta@example.com> wrote:[color=blue]
> Hi all you fine people!
>
> I have to design a way to print latest information on the frontpage, like
> about 'Note that Tonight's Rambo Excercise for Kids takes place at the
> sportsfield if the weather allows - Susanna"[/color]
[color=blue]
> My idea is that several people would update these lines, and that there
> would be e. g. five latest messges visible.[/color]
[color=blue]
> leave a message. The message would be added at the end of the file
> 'news.txt', the date and time of the message would be saved in the same
> file as well. Then there would be a script thet reads the text until the
> sixth date would be encountered, and prints each message on the frontpage.
> I thought I would even use <pre class="message"></pre> markup if necessary.[/color]
This is the way i would do it: (Avoiding searching latest 5 message in a
file etc)
Assuming you have already x posts in a file:
allposts.txt
Store the last 5 most recent posts in a file:
x+4.txt x+3.txt x+2.txt x+1.txt x.txt
(Say you already 10 posts, the files would be 14.txt, 13.txt, ...
10.txt)
Now each time a post is added, append it to allposts.txt and put it in a
file called x+6.txt. Remove the file x.txt
Next time a post is added, append it to allposts.txt and put it in a
file called x+7.txt. Remove the file x+1.txt
(In general: remove the x-5th file)
To show the most recent posts, instead of searching in allposts.txt just
display the 5 txt files ;)
--
http://home.mysth.be/~timvw