djmartins Posted August 1, 2010 Report Share Posted August 1, 2010 <?php $lietotaji=mysql_query("select * from users") or die(mysql_error()); while($users=mysql_fetch_array($lietotaji)) { $count=mysql_query("select COUNT(id) As daudzums from movie where niks='$users[1]' group by autors HAVING count(id) > '0' ORDER By daudzums DESC") or die(mysql_error()); while($rezultats=mysql_fetch_array($count)) { echo"$users[1] $rezultats[0]<br>"; } } ?> Problēma ir tajā, ka nesakārto saskaitītos rezultātus dilstošā secībā. Tiek izvadīts šādi -> juris 4 maris 1 edgars 3 Taču vajadzētu šādi -> juris 4 edgars 3 maris 1 Kur man varētu būt kļūda? Quote Link to comment Share on other sites More sharing options...
briedis Posted August 1, 2010 Report Share Posted August 1, 2010 Padomā loģiski, tu atlasi lietotājus (viņi NAV sakārtoti) un tad tu atlasi katram tam lietotājam skaitu. Tas viss ir jādara vienā kvērijā. Quote Link to comment Share on other sites More sharing options...
djmartins Posted August 1, 2010 Author Report Share Posted August 1, 2010 Paldies par padomu, it kā sanāca. 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.