Advertisement
Guest User

For NGGV

a guest
May 7th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. function top_ten_images($_limit) {
  2. global $wpdb;
  3. $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...)
  4. $qry .= ' FROM '.$wpdb->prefix.'nggv_votes';
  5. $qry .= ' WHERE';
  6. $qry .= ' pid != 0';
  7. $qry .= ' GROUP BY pid';
  8. $qry .= ' ORDER BY total DESC';
  9. $qry .= ' LIMIT '.$_limit;
  10. $top_piclist = $wpdb->get_results($qry);
  11. //var_dump($top_piclist);
  12. foreach ($top_piclist as $val) {
  13.  
  14. $top_list[] = nggdb::find_image($val->pid);
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement