Jump to content

Top Content


.Darkman

Recommended Posts

Hello Everybody,

 

I need some help displaying top content from my database.

 

For eg,

 

I have an article system.

I have two tables in the DB.

One is articles : containing article_id, title, and the article columns.

 

Other is the rating table containing article_id and a rating (btw 0-5).

 

 

Now what i want to do is display the Top 10 articles on the basis of their rating.

How do i do it ? I have thought in many ways. But none worked.

 

Please Help

 

 

Thank You

 

 

Link to comment
Share on other sites

$sql = "SELECT articles.article_id as id, articles.title, articles.article, rating.article_id, rating.rating FROM `articles` JOIN `rating` ON (articles.article_id = rating.article_id) ORDER BY `rating.rating` DESC LIMIT 0, 10";

 

anybody wanna back me up on this one...

Link to comment
Share on other sites

 

$sql = "SELECT rating.article_id as id, AVG(rating.rating) as article_rating, articles.article_id, article.title, article.article FROM rating JOIN `articles` ON (rating.article_id = articles.article_id) GROUP BY id ORDER BY `rating` DESC LIMIT 0,10";

$result = mysql_query($sql) or die(mysql_error());

while($row ....

Link to comment
Share on other sites

Okay, that may be complicated.

 

How about on a del.icio.us site ?

 

A link is saved. In the links table, the link and user_id are stored.

 

Top links are shown on the basis of how many people have saved it.

 

(i.e) a link with most occurrences in the links table will be on top and with least occurrences will be on bottom.

 

How shall this be done ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.