|
Top 10 script problems.
Hey everyone, i am trying to create a Top 10 script, and I am having problems. The way my tables are setup, is their is a table called ratings, that logs every rating of everything ont he site, then their is a feild that is item_id this relates to another table that has the item info in it. I am trying to take the average of ratings, find the top to for each item and match the item_id with the id int eh tutorials table, then out put the top 10. Here is what I have now:
[code:1:84317cc003] <?PHP
$querytut = "SELECT a.tutorial_id, a.tutorial_title, b.item_id, AVG(b.rating) as average FROM tutorials as a, ratings as b";
$querytut .= " WHERE a.tutorial_id='b.item_id' AND b.item_type='tutorial' GROUP BY a.tutorial_id ORDER BY average desc LIMIT 10";
$tutinfo = mysql_query($querytut) or die(mysql_error());
while($data=mysql_fetch_assoc($tutinfo)) {
$id = $data['tutorial_id'];
$rate = round($data['average'],2);
var_dump($data);
?>
<tr>
<td><a href="http://www.Graphics-Central.com/tutorials/index.php?id=<?PHP echo $data['tutorial_id']; ?>"><?PHP echo $data['tutorial_title']; ?></a> <?PHP echo $rate; ?></td>
</tr>
<?PHP
}
?>[/code:1:84317cc003]
I am not getting any errors, or results.
|