$types = array('1' => 0, '2' => 0, '3' => 0, '4' => 0); $result = dbquery("SELECT id, type FROM ".DB_PREFIX."type ORDER BY id ASC"); while (list($id, $type) = dbarraynum($result)): $types[$type]++; if (array_key_exists($type, $types) and $types[$type] <= 2) echo $id.' - '.$type.'
'; endwhile;