hey
i'm trying to do a script to use for updating news on my site. and so i have a page with a form where you type the news and title of it in, it's then written to a file using fwrite().. it then appears on the site like this:
- even older news
- old news
- new news
what i want to do is to have the oldest news at the bottom and the new news at the top..
i tried to do it like this:
<?php
$newsitem = $subject . "<br><br>" . $news;
$newsfile = "news.txt";
if (!($fp = fopen($newsfile, "w+"))) die ("Could not open $newsfile");
$oldnews = (string) fread($fp, filesize($newsfile));
$complete = $newsitem . $oldnews;
fwrite($fp, $complete);
fclose($fp);
?>
$subject and $news are from a form from the previous page and $oldnews is what was in news.txt before.. i use "w+" as i want to read and write and then remove what's in news.txt before writing $complete..
news.txt is then included on the main-page..
thing is.. i can't get this damn script to work, so any help at all would be greatly appreciated.. thanks in advance!