o666rland Posted November 26, 2005 Report Share Posted November 26, 2005 Sveicinaati! Veershos pie Jums kaa gudriem cilveekiem. Izmekleejos Googlee, Nigmaa utt. Atradu visu ko, be ne to ko man vajag. Situaacija taada. Ir table -> ID, PARENT, NAME_LV Itkaa visam vajadzeetu buut pareizi. Vajadziiba sekojosha. Atverot saitu nolasaas visi parenti ar veertiibu 0. Nekaadu probleemu. Kad uzspiezhu uz vienu no parenta (0) vajag paraadiit visas apakshketegorijas (SELECT * FROM cats WHERE (parent='$_GET["id"]')). Ar rekursijas metodi dabuju gatavu, tikai liidz 2 liimenim BET man vajag lai vareetu nolasiit neierobezhotaa liimenii. Piemeram ->Veljas mashiinas(id=1,parent = 0) ->Lielaas(id=2,parent = 1) ->Mazaas(id=3,parent = 1) -> Bosch (id=4, parent=3) utt. Toistj, uzreiz paraadiit hierarhiaalaa veidaa nav probleemu, bet lai paraadiitos visas kategorijas uzspiezhot uz kaadas kategorijas, lai paraadaas kategorijas SUBkategorijas (kuras pirms tam ir nosleeptas), uzspiezhot uz kaadu SUB kategoiju, lai paraadaas visas sub kategorijas SUB kategorijas utt. Meeginaaju 2 variantus -> ar javascript nesanaaca -> ar php es varu nolasiit tikai liidz 2 limenim un vsjo. Atvainojiet par slikto skaidrojumu, bet savaadaak nemaaceeju.. Ko Juus man ieteiktu? Tjipa tadu kaa www.euroshop.lv Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 meklee shajaa forumaa, vai bubu satura raadiitaajaa paskaties vismaz. nevaig muldeet ka esi mekleeji. tas te ir aprunaats no a - z :) Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 Es gan skatiijos shitam cauri, bet neatradu, ja taa saki, tad apskatiishos veelreiz... Link to comment Share on other sites More sharing options...
rpr Posted November 26, 2005 Report Share Posted November 26, 2005 nu ja raada tikai 2 limenjus, tad visticamaak, ka nepareizs skripts. pienjemu, ka tev vareetu buut, ka jauno $_GET['id'] nepieshkjir pareizi. neaizmirsti gan noraadiit, kad tai rekursijai jaabeidzaas, savaadaak buus muuzjiigais cikls otrs variants, kad daudz tev tie dati un netiek izmantoti indeksi un taimlimits iesleedzaas, bet shis gadiijums laikam tev nebuus. Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 http://cerber.expressshop.lv/ Apsties sho - varbuut labaak sapratiisi, nekaa izskaidroju....:) Kods ir sekojosh: --------------------------------------------------------------------------------------- class NavMenu { //var $theQuery; //var $link; var $menuArray = array(); function show_menu($id=0, $path="",$iid=0) { $connector = new DbConnector(); $db_result = $connector->query("SELECT id, parent ,name_lv FROM cats WHERE parent=$id ORDER BY id ASC"); echo '<ul class="id_nav"'.($id==0?'id="tree"':'').'>'; //echo '<ul '.($id==0?'id="left_menu"':'id="'.$id.'"').'>'; $i=0; $x = 0; while ($row = $connector->fetchArray($db_result)) { $i++; $newPath = $path .($path==''?'':'.'). $i; echo '<li>'.$newPath.'<a href="?step=cat&id='.$row['id'].'">'.$row['name_lv'].'</a>'; if($iid == $row["id"] && $iid > 0 ) { $this->show_menu($iid, $newPath); ++$x; } echo '</li>'; } printf("</ul>\r\n"); } // CLASS END } --------------------------------------------------------------------------------------- $menu = new NavMenu; if(isset($_GET["id"])) { $menu->show_menu(0,"",$_GET["id"]); } else { $menu->show_menu(); } --------------------------------------------------------------------------------------- Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 te pat tika kaut kur apspriests .... function menu($id,$parrent){ $all = select id,name,parrent from kateg where cat = $id //tas buutu kverijs while (){ echo '<a href="?id=$id">$name</a>'; menu($id,$parrent); } } kaut kaa taa... tas ir tiiri triviaali ... :) buutiiba lai buutu :) Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 (edited) bez taa $parrent nevar kaut kaa iztikt...? Un man nav taada lauka cat... :/ Edited November 26, 2005 by o666rland Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 ko man tagad dariit ka tev nau taada lauka ? iedod DB acces , sataisiishu DB :) Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 Kas tas taads par lauku vispaar ir un kam tajaa vajag buut...? Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 (edited) a tu padomaa :) keissofball variants, uznjems kaut kaadu projektu a rokas pa iisu un pa liiku .... :/ saradušies "jaunie talanti" kā sēnes pēc lietus ... Nevaig njemt projektu, ja zin ka nevarees tur nekaa izdariit .. Edited November 26, 2005 by Klez Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 (edited) Saprotu, kritika tas ir labi... Bet Tu man izskaidro, kaapeec nevar iztikt tikai ar id un parent? P.S. Man neviens neparasa vai es to varu vai nee - dari un viss.. Es saprotu, ka Tu esi gudrs shajaa jomaa taapeec es luudzu padomu, paliidziibu, ja vari paliidzeet luudzu, ja ne, nu tad neko... Edited November 26, 2005 by o666rland Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 kaapeec mums buutu jaastraa un tu sanjem naudu ? pastaasti luudzu. nu ja tu mums samaksaa, ka mees tev uztaisam, tad taa ir cita lieta :) Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 Driikst pajautaat kaapeec ir domaats forums? Link to comment Share on other sites More sharing options...
Klez Posted November 26, 2005 Report Share Posted November 26, 2005 taapeec, lai risinaatru probleemas paskaties te! http://php.lv/f/index.php?s=&showtopic=351...indpost&p=27915 Link to comment Share on other sites More sharing options...
o666rland Posted November 26, 2005 Author Report Share Posted November 26, 2005 Cieniitais, es jautaaju nevis gatavu skriptu, bet ieteikumu kaa risinaat sho probleemu. Man ir probleema, kam ir nepiecieshams risinaajums. Ja nedriikst dot risinaajumu, tad vismaz padomu kaa to risinaat. Link to comment Share on other sites More sharing options...
Recommended Posts