Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Problem z poprawnym ID przy komentowaniu newsów...
nightmoon
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 7.12.2007

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


Witam, Panowie mam problem z poprawnym odesłaniem na forum, żeby można było komentować na nim newsa, każde ID przy opcji komentowania jest identyczne, zapewne jest to problem z pętlą ale nie mam za choinkę pojęcia jak to zrobić, kod wygląda następująco:

  1. $res = mysql_query("SELECT * FROM news ORDER BY added DESC LIMIT 5") or sqlerr(__FILE__, __LINE__);
  2.  
  3. if (mysql_num_rows($res) > 0) {
  4. print("<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td align=center>\n");
  5.  
  6. while($array = mysql_fetch_array($res)) {
  7.  
  8. print("<table class='kratka' width=100% border=1 cellspacing=0 cellpadding=5><tr><td class='colhead' colspan='2'>" . gmdate("Y-m-d G:i:s",strtotime($array['added'])) . " - " . $array['title'] . "");
  9.  
  10.  
  11. $ros = mysql_query("SELECT id FROM topics WHERE forumid = 77 ORDER BY id DESC LIMIT 1") or sqlerr();
  12. while ($orr = mysql_fetch_assoc($ros)) {
  13. $topicid = $orr["id"];
  14. }
  15.  
  16. print(" <font class='small'>[<a class=altlink href='forums.php?action=viewtopic&topicid=$topicid'><b><u>Skomentuj</u></b></a>]</font>");
  17.  
  18. if (get_user_class() >= UC_MODERATOR) {
  19. print(" <font class='small'>[<a class=altlink href=news.php?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><b><u>Edycja</u></b></a>]</font>");
  20. print(" <font class='small'>[<a class=altlink href=news.php?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><b><u>Usuń</u></b></a>]</font></td></tr>");
  21. }
  22. print("<tr><td width='10%'><img src=" . htmlspecialchars($array["img"]) . "></td><td class='text' width='90%'>" . format_comment($array["body"],0) . "</td>");
  23.  
  24.  
  25. print("</tr></table><br>");
  26.  
  27. }
  28.  
  29. }


Jak zmienię zapytanie na:

  1. $ros = mysql_query("SELECT id FROM topics WHERE forumid = 77 ORDER BY id DESC LIMIT 2") or sqlerr();


Wtedy opcja [Skomentuj] przy obudwu postach zmienia wartość na poprzedni temat napisany w forumid = 77 np. 3030...

Jak dopisać tam pętle, żeby to działało?

Zdjęcie:

(IMG:http://img237.imageshack.us/img237/6128/problemnv.jpg)
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: 24.08.2025 - 19:29