Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Prosty Shoutbox
Arsanael
post
Post #1





Grupa: Zarejestrowani
Postów: 65
Pomógł: 0
Dołączył: 4.06.2009

Ostrzeżenie: (0%)
-----


Mam mały problem z shoutboxem. Udało mi sie go zrobić ale problemem jest to ze nowe wiadomosi dodają sie na koncu gdyż w funkcji fopen uzylem atrubutu "a" gdyz nie kasuje reszty pliku. Teraz pytanie jak zrobić tak zeby bylo dobrze i nowe shouty dodawały sie na poczatku ?

kod:

  1. function add_shout($message,$from_user,$data,$time,$handle)
  2. {
  3. $file = fopen($handle,"a");
  4. fputs($file,$data);
  5. fputs($file,' - ');
  6. fputs($file,$time);
  7. fputs($file,' ( ');
  8. fputs($file,$from_user);
  9. fputs($file,' ) : ');
  10. fputs($file,$message);
  11. fputs($file, ' | ');
  12. fclose($file);
  13. header("Location: index.php");
  14. }


Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Flameman
post
Post #2





Grupa: Zarejestrowani
Postów: 9
Pomógł: 1
Dołączył: 21.08.2009

Ostrzeżenie: (0%)
-----


Na przykład:
  1. function add_shout($message,$from_user,$data,$time,$file_name)
  2. {
  3. $zm .= $data.' - '.$time.' ( ').$from_user.' ) : '.$message. ' | ';
  4. $zm .= file_get_contents($file_name);
  5. file_put_contents($file_name,$zm);
  6. header("Location: index.php");
  7. }

Wybacz,że się tak podpinam,ale miałem już napisany kod i szkoda mi go było:P
EDIT:Poprawione

Ten post edytował Flameman 26.08.2009, 13:34:04
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 01:17