2

I designed a blog and its retrieving data from database dynamically.Now i want that the blog that has most comments is displayed on the top. So anyone who can help me with this.I am posting the snapshots my page where the popular blogs is to be displayed.

Area where the popular blog are displayed.

http://s1272.photobucket.com/user/Ahad_Murtaza/media/Untitled_zps329dc86b.png.html

4

2 回答 2

1

Before asking try to do something or try to google it...

Your Answer -- You can use pagination for display the data...

Or you can do some query work --

SELECT SUM(something) AS fieldname
FROM tablename
ORDER BY fieldname

By taking that SUM of comments we can display.

Hope this will help !!

于 2013-05-09T05:33:29.630 回答
0

AS i seen your images in link a query should be like this to display as per your output Please set column name as per your need to display from table here is just query

select
  Comment.blog_id,
  count(Comment.commentId) as number_of_comments,blog.title
from
  Comment
LEFT JOIN blog
  ON Comment.blog_id=blog.blog_id
group by
  Comment.blog_id,
order by
  number_of_comments desc
limit 10;

let me know if i can help you more

于 2013-05-09T05:32:02.997 回答