Mam taki problem: gdy chcę dodać nowszy news na górę to coś nie działa, a jak na dół to działa.
formularz(news_admin.php):
<!DOCTYPE HTML PUBLIC "-//W3C//
DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-type"
content="text/html;
charset=ISO-8859-2" />
<title>Formularz</title>
</head>
<body>
<form action="dodaj_news.php"
method="post">
Treść:<br>
<textarea name="tresc_txt"
rows="10" cols="40" >
</textarea><br>
<input type="submit"
value="Wyślij">
</form>
</body>
</html>
Skrypt który ma dodać news(dodaj_news.php):
<!DOCTYPE HTML PUBLIC "-//W3C//
DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-type"
content="text/html;
charset=ISO-8859-2" />
<?php
$tresc=$_POST["tresc_txt"];
echo "<b>Wprowadzono następujące
dane:</b><p>\n";
echo "<b>Treść</b><br>\n";
$tresc=nl2br($tresc);
echo $tresc;
$miesiace = array(
'January' => 'Stycznia',
'February' => 'Lutego',
'March' => 'Marca',
'April' => 'Kwietnia',
'May' => 'Maja',
'June' => 'Czerwca',
'July' => 'Lipca',
'August' => 'Sierpnia',
'September' => 'Września',
'October' => 'Października',
'November' => 'Listopada',
'December' => 'Grudnia'
);
$day = strtr(date('j F Y, G:i'), $miesiace);
$data = '<p class="data"><b>Dodano:</b>' . $day . '</p>';
$tresc = '<p class="TRESCNEWS">' . $tresc . '</p>';
$tekst = $data . $tresc . '</p><br><hr>';
if (!empty($tresc))
{
$plik = fopen("newsy.txt", "r+");
fputs($plik, $tekst);
fclose($plik);
}
?>
</body>
</html>
Plik który wyświetla newsy(news.php):
<!DOCTYPE HTML PUBLIC "-//W3C//
DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-type"
content="text/html;
charset=ISO-8859-2" />
<?
$plik = fopen("newsy.txt", "a+");
fpassthru($plik);
fclose($plik);
?>
</html>
Wszystkie newsy są zapisywane w pliku newsy.txt. Nie wiem w czym tkwi problem. :-/ [???]