בעיה עם רקורסיה..

Fly2High

New member
בעיה עם רקורסיה..

שלום
אני רוצה לבנות פורום, והרקורסיה להצגה של ההודעות לא עובדת בדיוק כמו שצריך. זה מציג לי רק שרשורים ארוכים.. ולא מציג לי פיצול בשרשור. בתמונה המצורפת- כחול זה מה שמוצג, אדום זה מה שלא מוצג, אבל כל מה שאתם רואים מתוכנן בDB עם הPARENTID. סגול זו תגובה ראשונית.. כלומר- יש הודעה ראשית, תגובה ראשית, תת תגובה, תת תת תגובה.. זה מציג לי רק שרשראות ארוכות של כחולים, אם השרשור מתפצל באמצע או אפילו אחרי תת תגובה אחת זה לא מציג אותו.. אשמח לעזרה..
תודה
 

Tbear

New member
איך אתה רוצה שיעזרו לך???

אנשים פה לא יכולים לנחש מה הקוד שלך.. אם תעלה את הקוד אולי למישהו יהיה רעיון.
 

Fly2High

New member
כן טעות קטנה מצידי.. ../images/Emo6.gif

הממ הכוונה שלי היתה שמישהו יוכל לעזור לי לכתוב את הפעולות מילולית.. בכל מקרה- זה הקוד:
<% Function showMessage(idn) Set subReply = con.execute ("SELECT * FROM Replys Where ParentID=" & idn & " ORDER by id") if NOT subReply.bof AND NOT subReply.eof then ' חישוב המרחק מצד ימין pad = subReply("level") padding = pad * 14 padding = padding ' הצגת תוכן התגובה Response.Write "<tr>" Response.Write "<td align='right' class='respond_1' style='background-color: " & color & "; padding-right: " & padding & ";'>" Response.Write "<img src='http://rotter.name/nor/Images/reply_message.gif' border='0' />" Response.Write " " & subReply("Title") & "</td>" Response.Write "<td align='center' class='m_details' style='background-color: " & color & ";'>" & subReply("Username") & "</td>" Response.Write "<td dir='ltr' align='center' class='m_details' style='background-color: " & color & ";'><b>נכתב ב:</b> " & subReply("Date_Written") & " " & subReply("Hour_Written") & "</td>" Response.Write "</tr>" subid = subReply("id") ' בדיקה אם יש להודעה הזו תתי תגובות Set test = con.execute("SELECT * FROM Replys Where ParentID=" & subid) if not test.bof and not test.eof then set test = nothing set subReply = nothing 'קריאה לפונקציה showMessage(subid) end if end if end Function 'הצגת תגובה ראשית Set Reply = con.execute ("SELECT * FROM Replys Where ParentID=" & id & " ORDER by id") if NOT Reply.bof AND NOT Reply.eof then do until Reply.eof %> <tr> <td align="right" class="respond_1" style="background-color: <%=color%>; padding-right: 8;"> <img src="http://rotter.name/nor/Images/message.gif" border="0"> <%=Reply("Title")%></td> <td align="center" class="m_details" style="background-color: <%=color%>;"><%=Reply("Username")%></td> <td dir="ltr" align="center" class="m_details" style="background-color: <%=color%>;"><b>נכתב ב:</b> <%=Reply("Date_Written")%> <%=Reply("Hour_Written")%></td> </tr> <% 'הצגת תת תגובה ראשונה וקריאה לפונקציה של ההצגה Set bott = con.execute ("SELECT * FROM Replys Where ParentID=" & Reply("id") & " ORDER by id") if not bott.bof and not bott.eof then do until bott.eof pad = bott("level") padding = pad * 14 Response.Write "<tr>" Response.Write "<td align='right' class='respond_1' style='background-color: " & color & "; padding-right: " & padding & ";'>" Response.Write "<img src='http://rotter.name/nor/Images/reply_message.gif' border='0' />" Response.Write " " & bott("Title") & "</td>" Response.Write "<td align='center' class='m_details' style='background-color: " & color & ";'>" & bott("Username") & "</td>" Response.Write "<td dir='ltr' align='center' class='m_details' style='background-color: " & color & ";'><b>נכתב ב:</b> " & bott("Date_Written") & " " & bott("Hour_Written") & "</td>" Response.Write "</tr>" subid = bott("id") Set test = con.execute("SELECT * FROM Replys Where ParentID=" & subid) if not test.bof and not test.eof then set test = nothing set subReply = nothing 'קריאה לפונקציה showMessage(subid) end if bott.movenext loop end if Reply.movenext loop end if​
 

Fly2High

New member
../images/Emo208.gif../images/Emo208.gif../images/Emo105.gif

מישהו? |מילים כדי שיקפיץ| |מילים כדי שיקפיץ| |מילים כדי שיקפיץ|
 

בסג

New member
הסיבה היא...

שבפונקציה showMessage לא עשית לולאה, אז בSQL אתה שולף את כל הרשומות, ומתייחס רק לראשונה. (כמו כן, שים לב, אתה לא סוגר ומשחרר RS-ים, שזהו פשע כנגד השרת.)
 

Fly2High

New member
חשבתי על זה...

אבל לא הצלחתי לנסח את זה כמו שצריך וירדתי מזה :| יש מצב לעזרה קצת? בניסוח של הלולאה? חח תודה P:
 

בסג

New member
קלי קלות

במקום
if NOT subReply.bof AND NOT subReply.eof then ... ... ... end if​
צריך להיות:
while NOT subReply.bof AND NOT subReply.eof ... ... ... subReply.movenext wend​
 
למעלה