Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function top_ten_images($_limit) {
- global $wpdb;
- $qry = 'SELECT pid, SUM(vote) AS total, AVG(vote) AS avg, MIN(vote) AS min, MAX(vote) AS max, COUNT(vote) AS num'; //yes, no joins for now. performance isnt an issue (i hope...)
- $qry .= ' FROM '.$wpdb->prefix.'nggv_votes';
- $qry .= ' WHERE';
- $qry .= ' pid != 0';
- $qry .= ' GROUP BY pid';
- $qry .= ' ORDER BY total DESC';
- $qry .= ' LIMIT '.$_limit;
- $top_piclist = $wpdb->get_results($qry);
- //var_dump($top_piclist);
- foreach ($top_piclist as $val) {
- $top_list[] = nggdb::find_image($val->pid);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement