Jump to content

MYsql advanced querying


marklarah

Recommended Posts

They could make a tv show called that ^_^

 

Seriously, I have a linking system, which er...links to things.

There is the ability to rate links, but due to like spamming, and one vote per user, I have the votes in a separate table from the links. I know a link or a join will need to be used, but how to i make a query where it displays the links in the links table descending ordered by the most popular (highest votes).

 

---My query for displaying the rank of a link is---

$result2 = mysql_query("SELECT SUM(rating) FROM `late` WHERE `lid` = '$link'");

$row = mysql_fetch_array($result2);

echo ($row['SUM(rating)'] / $num);

Where $link equals the Link ID and $num equals the amount of rows counted in the votes table where the link ID equals $link. The rating is out of 10

 

---My query for displaying the links normally is---

$result = mysql_query("SELECT * FROM `blue` ORDER BY `date` DESC LIMIT 10");

 


 

So how would I join the two to display the links ordered by rank?

 

Help much appreciated

 

Thanks - Mark (ps, cookies to whoever helps :)

 

 

 

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.