I am using this ajax rating system 1.7 at my site. All is working fine but I couldn't figure out how to pull TOP 10 programs that are best rated. Here's the code: <? function getTopRated($limit, $table, $idfield, $namefield){ $result = ''; $sql = "SELECT COUNT(ratings.id) as rates,ratings.rating_id,".$table.".".$namefield." as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating FROM ratings,".$table." WHERE ".$table.".".$idfield." = ratings.rating_id GROUP BY rating_id ORDER BY rates DESC,rating DESC LIMIT ".$limit.""; $sel = mysql_query($sql); $result .= '<ul class="topRatedList">'."\n"; while($data = @mysql_fetch_assoc($sel)){ $result .= '<li>'.$data['thenamefield'].' ('.$data['rating'].')</li>'."\n"; } $result .= '</ul>'."\n"; return $result; } ?> and to pullout TOP 10 or 100 (whatever limit you want) code: <? echo getTopRated(10,'sites','sites_id','sites_title'); ?> My table name is sites, idfield = id and namefield = title and the ratings table is separate from sites table. so how to I get the TOP 10 or 100 program with best ratings??? Sorry for my english