<?php

/* No empty dropdowns please */
if ($field != '' AND $id != '') {
	$out = wp_cache_get( 'wct_select' , 'wct');
	if ($out == false) {
		$limit = (integer)$limit;
		if ($limit <= '0') { $limit = '1'; }
		$qry = $wpdb->get_results("SELECT `".mres($field)."` AS `item`,count(".mres($field).") AS `anz`  FROM `".$wpdb->prefix."wct".mres($id)."` GROUP BY `".mres($field)."` ORDER BY `anz` DESC LIMIT ".$limit.";");
		if (count($qry) >= '1') {
			$out = "<select onChange=\"selector('".$field."')\" style=\"font-weight: bold;\" id=\"wctdrop_".$field."\" name=\"wctdrop_".$field."\"><option style=\"font-weight: bold;\" value=\"\">".$maintext."</option>";
			foreach ($qry as $row) {
				$out .= "<option style=\"font-weight: normal;\" value=\"".$row->item."\" ";
				if ($_GET['wctdrop'] == $row->item) { $out .= " selected"; }
				$out .= ">".$row->item." (".$row->anz.")</option>";
			}
			$out .= "</select>";
		}
		/* If field not existing or no options to dropdown, no cache! */
		if ($out != '') { wp_cache_set( 'wct_select', $out, 'wct', $this->settings['wct_cachetime']); $include_js = '1'; }
	}
}

?>