Ahad Murtaza
Ahad Murtaza

Reputation: 27

How to show popular blog post

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

Upvotes: 2

Views: 123

Answers (2)

FrontEnd Expert
FrontEnd Expert

Reputation: 5803

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 !!

Upvotes: 1

liyakat
liyakat

Reputation: 11853

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

Upvotes: 0

Related Questions