this is the sql call I use
PHP Code:
SELECT a.code,b.primaryimage FROM ".$prefix."adoptables AS a JOIN ".$prefix."levels AS b ON b.type=a.type AND a.whenisavail !='promo' AND a.whenisavail !='mystery' AND a.shop=b'0' AND a.grlelevel <= '$group' AND b.thisislevel=0 ORDER BY RAND() LIMIT 8";
My code is now greatly optimized from the original.. so you will have to understand some php to break it down.. but thats what I use.