Jump to content

arranging num_rows


corillo181

Recommended Posts

i got this code

but 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.