%d total votes\n",$n); foreach($awardscat[$year] as $x=>$name) { $sql = "SELECT prods.id,prods.name,prods.type,count(*) as c "; $sql .= " FROM awardscand_".$year." "; $sql .= " JOIN prods ON awardscand_".$year.".cat".$x."=prods.id "; $sql .= " GROUP BY prods.id ORDER BY c DESC,name"; $r = mysql_query($sql) or die(mysql_error()); echo "\n"; echo "\n"; while ($o = mysql_fetch_object($r)) { printf("\n",($n++&1)+1); echo "\n"; echo "\n"; } echo "
#".$x." - ".$name."
"; foreach(explode(",",$o->type) as $v) { printf("",$types[$v]); } echo "".$o->name.""; echo "".$o->c." votes
\n"; } ?>