corillo181 Posted December 31, 2006 Share Posted December 31, 2006 i got this codebut i want to knwo if i can arrage from one to 10 depending on wich one has the most comment.[code]<?php//counting the comments of the picture$c=mysql_query("SELECT comment_id FROM tra_pcomment WHERE photo_id='".$alphoto['photo_id']."'")or die(mysql_error());$count=mysql_num_rows($c);if($count){echo $count ." comments";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32399-arranging-num_rows/ Share on other sites More sharing options...
fert Posted December 31, 2006 Share Posted December 31, 2006 you can with the ASC sql keyword Link to comment https://forums.phpfreaks.com/topic/32399-arranging-num_rows/#findComment-150464 Share on other sites More sharing options...
corillo181 Posted December 31, 2006 Author Share Posted December 31, 2006 yeha i have that in mind but how would put it.. like photo_id asc? thats where i have the problem. Link to comment https://forums.phpfreaks.com/topic/32399-arranging-num_rows/#findComment-150468 Share on other sites More sharing options...
fert Posted December 31, 2006 Share Posted December 31, 2006 [code]SELECT * FROM `tra_pcomment` WHERE `photo_id`='$photo_id' ORDER BY `num_comments` ASC LIMIT 10[/code] Link to comment https://forums.phpfreaks.com/topic/32399-arranging-num_rows/#findComment-150470 Share on other sites More sharing options...
Barand Posted December 31, 2006 Share Posted December 31, 2006 This will give the top-ten comment counts for each photo_id, highest count first[code]<?php$c=mysql_query("SELECT photo_id , COUNT(*) as numcomments FROM tra_pcomment GROUP BY photo_id ORDER BY numcomments DESC LIMIT 10") or die(mysql_error());?>[/code] Link to comment https://forums.phpfreaks.com/topic/32399-arranging-num_rows/#findComment-150487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.