Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Zapętlanie pętli, wyśiwetlanie wszystkich wyników
Kristof
post
Post #1





Grupa: Zarejestrowani
Postów: 33
Pomógł: 1
Dołączył: 15.12.2005

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


Oto mój kod:
  1. <?php
  2. $idsnat = mysql_query("SELECT id FROM snatched where userid=$id ORDER BY id") or sqlerr();
  3. while ($idsnatch = mysql_fetch_assoc($idsnat)) {
  4. $r = mysql_query("SELECT name, seels, loolers, cater FROM elek WHERE id=$idsnatch[id] ORDER B
    Y name"
    );
  5. if (mysql_num_rows($r) > 0)
  6. {
  7. $completed = "<table class=main border=1 cellspacing=0 cellpadding=5>n" .
  8. "<tr><td class=colhead>Type</td><td class=colhead>Name</td><td class=colhead>Seels</td><td class=colhead>Loolers</td></tr>n";
  9. while ($a = mysql_fetch_assoc($r))
  10. {
  11. $r2 = mysql_query("SELECT name, image FROM categor WHERE id=$a[cater]") or sqlerr(__FILE__, __LINE__);
  12. $a2 = mysql_fetch_assoc($r2);
  13. $cat = "<img src="/pic/$a2[image]" alt="$a2[name]">";
  14. $completed .= "<tr><td style='padding: 0px'>$cat</td><td><a href=details.php?id=" . $idsnatch["id"] . "&hit=1><b>" . htmlspecialchars($a["name"]) . "</b></a></td>" .
  15. "<td align=right>$a[seels]</td><td align=right>$a[loolers]</td></tr>n";
  16. }
  17. $completed .= "</table>";
  18. }
  19. }
  20. ?>

i gdzie na koncu wywołanie $completed. Zwraca mi tylko jeden wynik. GDzieś się pozapętlałem i się pogubiłem. Wyników powinno być wiele. Proszę o pomoc dzieki.
Go to the top of the page
+Quote Post
kszychu
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 712
Pomógł: 23
Dołączył: 27.10.2003
Skąd: z kontowni

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


W pętli w obu przypadkach powinno być $completed .= Ty na początku masz $completed = Popraw to.
Go to the top of the page
+Quote Post
Kristof
post
Post #3





Grupa: Zarejestrowani
Postów: 33
Pomógł: 1
Dołączył: 15.12.2005

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


no prosze jedna kropeczka a tyle zmienia. Co prawda jeszcze musze poprawić bo robią mi sie nowe tabele całe a nie jako kolumny ale do tego już dojde jakoś. Dzieki kszychu.
Go to the top of the page
+Quote Post

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: 22.08.2025 - 20:03