here is my problem:
i am using this simple script -->
<?php
if ($message)
{
$message = ereg_replace("\r\n\r\n", "\n<p>, $message);
$date = date("l, F j Y, h:i a");
$message = "<b>$name</b> -- <p> <i>$date</i><p>$message<br><hr>
$fp = fopen (basename($PHP_SELF) . ".comment", "a");
fwrite ($fp, $message);
fclose ($fp);
}
@readfile(basename(($PHP_SELF . ".comment")));
?>
the "$message" is taken from a standard form and the two together make a very simple guestbook / message board.
messages are contained in a simple text file with the ".comment" extension given to it (as shown above).
my problem is that the most recent post to the board is placed at the bottom of the message list instead of the top....so that the message order goes from oldest message first to newest message last -- backwards !!!
obviously this is because i am using "a" as the fopen mode.
if i add "rewind($fp)" and change the fopen mode to r+ it writes the newest data at the top of the text file (where i want it) but it overwrites a few of the lines at the top of the file!!!
i read somwhere that you can use multiple modes in fopen, and that using a combo of "aw" as the mode should fix my problem -- adding new data to the top of the text file (which is holding the messages) without erasing any data that is already there. however, this solution never works!!!
i have tried everything that i know and still can't find a solution that works well....
can anyone help me???