Jackal Posted January 16, 2008 Report Share Posted January 16, 2008 (edited) function show($parent){ $query = mysql_query("SELECT id, parent, kautkas FROM tabula WHERE parent='$parent' ORDER BY sort ASC"); if(mysql_num_rows($query) > 0){ $out .= ($parent == 0 ? '<ul class="mktree">' : '<ul>'); while($row = mysql_fetch_array($query)){ $out .= '<li>'.$row['kautkas']; $this->show($row['id']); $out .= '</li>'; } $out .= '</ul>'; } return $out; } Šis tiek likts temleitā: $klase->show(0); Problēma ir tāda, ka neizvada pareizi html'u, ja $out .= vietaa lietoju echo, tad viss ir pareizi, bet es nevaru lietot echo, jo izmantoju templeitu sistēmu. return šaja funkcijā it kā nevar lietot, jo tad nestrādā rekursija, bet lai ar šo $klase->show(0); varētu izvadīt html'u ir vajadzīgs return. Ir kādi risinājumi? Edited January 16, 2008 by Jackal Link to comment Share on other sites More sharing options...
bubu Posted January 16, 2008 Report Share Posted January 16, 2008 Kas tieši tev tur neizvadās pareizā html'ā? btw tev tur $out mainīgais ir neinicializēts, kad pirmo reizi to lieto. Link to comment Share on other sites More sharing options...
dmitriy Posted January 16, 2008 Report Share Posted January 16, 2008 $this->show($row['id']); nomaini uz $out .= $this->show($row['id']); Link to comment Share on other sites More sharing options...
Jackal Posted January 16, 2008 Author Report Share Posted January 16, 2008 Jā par šitādu variantu neiedomājos $out .= $this->show($row['id']); Tagad viss darbojas. Bet vai tad return nepārtrauca funkcijas darbību? Paldies! Link to comment Share on other sites More sharing options...
Aleksejs Posted January 16, 2008 Report Share Posted January 16, 2008 return atgrieza funkcijas vērtību. Link to comment Share on other sites More sharing options...
Recommended Posts