Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zapisywanie wyników to tablicy i ich wyświetlenie
pr0woKator
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 1
Dołączył: 9.02.2012

Ostrzeżenie: (10%)
X----


Witajcie!

Mam małą zagwozdkę, mianowicie:

Posiadam pentlę:

  1. for ($i = 0; $i < $tmpcount; $i++) {}


Która generuje działanie tylko dla wybranych przezemnie ID.

W tej pętli posiadam pętle While która wyświetla informacje na temat przedmiotów których ID zostało wybrane. Pod pętlą for posiadam zmienne $naglowek oraz $stopka.

Z $naglowek, danych ktore sa wypluwane przez petle while oraz $stopka, chcę utowrzyc plik tekstowy. Problem w tym, że gdy wybiorę więcej niż jedno ID zawsze dostaję tylko ostatni wynik pętli (No tak logiczne (IMG:style_emoticons/default/nerdsmiley.png) ).

Proszę podpowiedzcie mi jak zrobić abym do pliku mógł wyprintować więcej wyników. Szablon mojego skryptu:


  1.  
  2. for ($i = 0; $i < $tmpcount; $i++) {
  3. $naglowek = 'naglowek';
  4. $stopka = 'stopka';
  5.  
  6. $dane = $db->query("bla bla");
  7. while($wynik = $dane->fetch_assoc())
  8. {
  9. $fdane = 'wyniki z bazy';
  10. }
  11.  
  12. $dane = $naglowek.''.$fdane.''.$stopka;
  13. $plik = fopen('x.xml','w+');
  14. fputs($plik, $dane);
  15. }
  16.  
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
W jakim kierunku próbujesz mnie ustawić, nie bardzo wiem do czego dążysz.
Dąże, bys odrobine sam pomyslal i wybral z podanych tu parametrow ten wlasciwy:
Cytat
'r' Open for reading only; place the file pointer at the beginning of the file.
'r+' Open for reading and writing; place the file pointer at the beginning of the file.
'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
'x+' Create and open for reading and writing; otherwise it has the same behavior as 'x'.
'c' Open the file for writing only. If the file does not exist, it is created. If it exists, it is neither truncated (as opposed to 'w'), nor the call to this function fails (as is the case with 'x'). The file pointer is positioned on the beginning of the file. This may be useful if it's desired to get an advisory lock (see flock()) before attempting to modify the file, as using 'w' could truncate the file before the lock was obtained (if truncation is desired, ftruncate() can be used after the lock is requested).
'c+' Open the file for reading and writing; otherwise it has the same behavior as 'c'.


To naprawde nic skomplikowanego.... skoro ci napisale, ze znacznik nie ma byc na poczatku to znaczy ze ma byc na koncu. A teraz wyczytaj ktory parrametr ustawia znacznik na koncu. Podpowiedź: A - no jak teraz dasz zly to nie wiem..... (IMG:style_emoticons/default/wink.gif)

Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 12.10.2025 - 19:16