forSilence Posted October 10, 2010 Report Share Posted October 10, 2010 Taisu useru lapu, kad visu pabeidzu nokļuvu pie lista kur būs redzami visi lietotāji. Un saskāros ar problēmu. Man katru useri parāda 3 reizes. Un nezinu kā to labot. Rekur skīns: Un rekur tieši tā koda daļa else{ $query = mysql_query("SELECT * FROM `ibf_members`, `ibf_member_extra` "); while($row = mysql_fetch_array($query)){ switch($row['avatar_type']) { case 'upload': $avatar = "forums/uploads/". $row['avatar_location']; break; case 'url': $avatar = $row['avatar_location']; break; default: $avatar = "images/noavatar.png"; break; } echo ' <div id="video_list"><div class="video"> <table><tr> <td><img src="'.$avatar.'" width="30" height="30" /></td> <td><a href="?do=user&id='.$row['id'].'">'.$row['members_display_name'].'</a></td> </tr></table></div></div>'; } } Jau iepriekš paldies Quote Link to comment Share on other sites More sharing options...
Faks Posted October 10, 2010 Report Share Posted October 10, 2010 (edited) $query = mysql_query("SELECT * FROM `ibf_members`, `ibf_member_extra` ORDER BY user_level desc"); respektivi pec vinu limena var sakartot vai pec id . Edited October 10, 2010 by Faks Quote Link to comment Share on other sites More sharing options...
Леший Posted October 10, 2010 Report Share Posted October 10, 2010 Tev pieprasījumā ir 2 tabulas. Ja otrā tabulā ir 3x vairāk ierakstu, tad protams, būs 3x vairāk rezultātu. Taisi join vai subquery. Visādā ziņā, SELECT * FROM `ibf_members`, `ibf_member_extra` ir nepareizs query. Quote Link to comment Share on other sites More sharing options...
codez Posted October 10, 2010 Report Share Posted October 10, 2010 tu taisi JOIN-u, kur user tabulu joino ar citu tabulu, tāpēc saņem pilnu join-u. Tev vajag uzrakstīt join-ošanas nosacījumu. Quote Link to comment Share on other sites More sharing options...
forSilence Posted October 10, 2010 Author Report Share Posted October 10, 2010 Varētu kko sīkāk par JOIN, kā viņu pareizāk lieto un kur viņu lieto. Iekš php.net neko neatradu. Quote Link to comment Share on other sites More sharing options...
Faks Posted October 10, 2010 Report Share Posted October 10, 2010 (edited) Padališos ar materialu no saviem kursiem kodētaju kursiem es būšu ļot priecīgsi ja tiktu izlikts vel sadaļā noderīgs . http://content.wuala...pekti.docx?dl=1 Edited October 10, 2010 by Faks Quote Link to comment Share on other sites More sharing options...
forSilence Posted October 10, 2010 Author Report Share Posted October 10, 2010 Padališos ar materialu no saviem kursiem kodētaju kursiem es būšu ļot priecīgsi ja tiktu izlikts vel sadaļā noderīgs . http://content.wuala...pekti.docx?dl=1 Man neiet ši faila formāts. Quote Link to comment Share on other sites More sharing options...
Faks Posted October 10, 2010 Report Share Posted October 10, 2010 (edited) Man neiet ši faila formāts. http://viewer.zoho.com/docs/ldxwcb Ja kādam par maz tad varu piedāvāt vienu konspektu vel :) http://viewer.zoho.com/docs/rdb38d Iesaku novlikt un ar notepad vai notepad++ lasit tad var saprast kas tur ir :) Edited October 10, 2010 by Faks Quote Link to comment Share on other sites More sharing options...
forSilence Posted October 10, 2010 Author Report Share Posted October 10, 2010 Kāds varētu iedot gatavu pareizu queru es nevaru nekādi saprast kā pareizi viņu lieto. Quote Link to comment Share on other sites More sharing options...
Roberts.R Posted October 11, 2010 Report Share Posted October 11, 2010 PS - Google Docs atpazīst vairumu populārāko failu formātus ;) Man personīgi ir grūti spriest, ja nezinu Tavas tabulas(-u) struktūras. Quote Link to comment Share on other sites More sharing options...
forSilence Posted October 11, 2010 Author Report Share Posted October 11, 2010 Nu man ir tagad šādi: mysql_query("SELECT id,members_display_name,mgroup FROM ibf_members"); mysql_query("SELECT avatar_location,avatar_type FROM ibf_member_extra"); \ Un to visu apvienot ar vienu funkciju jeb JOIN. Biku pameklēju pa skriptiem un atradu. mysql_query("SELECT id,members_display_name,mgroup FROM ibf_members JOIN ibf_member_extra ON (avatar_location = avatar_type"); Bet man nesanāca, lūdzu pielabot, lai strādātu. Quote Link to comment Share on other sites More sharing options...
Val Posted October 11, 2010 Report Share Posted October 11, 2010 (edited) echo mysql_error() pēc kverija un izlasi, kas pa vainu. Es liktu uz to, ka jāpieraksta trūkstošie tabulu nosaukumi pirms id, members_blablbla, mgroup, avatar_location utt. Mysql nav kristāla lode, kura parāda no kuras tabulas konkrētos kolonnu nosaukumus vēlies izvilkt, salīdzināt. Edited October 11, 2010 by Val Quote Link to comment Share on other sites More sharing options...
forSilence Posted October 12, 2010 Author Report Share Posted October 12, 2010 Visu sataisīju Lūk kāds query's iznāca: mysql_query("SELECT ibf_members.members_display_name,ibf_member_extra.avatar_location,ibf_members.id,ibf_member_extra.avatar_type FROM ibf_members LEFT JOIN ibf_member_extra ON ibf_members.id = ibf_member_extra.id") Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.