<?

function kk_kategoria_form() {

	include_once('db.inc.php');

	printf("
	<FORM ACTION=%s METHOD=GET>Földrajzi szűrés: 
		<SELECT NAME=filter>
		<OPTION VALUE=0>Mindenhol</OPTION>
		<OPTION VALUE=100>Budapest</OPTION>
	", 'cimtar.php');

		$stmt="SELECT * FROM kk_megye WHERE INSTR(kk_megye.nev, 'Budapest')=0 ORDER BY nev";
		
		$mydb = new db();
		$result=$mydb->query($stmt);

		while ($row = mysql_fetch_object($result)){
			printf("<OPTION VALUE=%s>%s</OPTION>\n", $row->id, $row->nev);
		}



	printf("</SELECT>");

	$ret = p_lista();

	printf("<INPUT TYPE=SUBMIT VALUE=OK></FORM>");
}


function p_lista(){

	include_once('db.inc.php');

echo '<hr>';

	$mydb = new db();
	$stmt="SELECT * FROM kk_kategoria ORDER BY nev";
	$result=$mydb->query($stmt);

	$numrows=mysql_num_rows($result);

	while ($row = mysql_fetch_object($result)) {
		printf("<tr><td width=\"212\" valign=\"top\" bgcolor=\"#FFFFF6\"><a href=cimtar.php?c=%s&filter=0>%s %s</a></td></tr>", $row->id, $row->nev, c_lista($row->id));
	}
}


function c_lista($c){

	include_once('db.inc.php');

	if($c==0 || !isset($c)){
		return null;
		exit;
	}

	$mydb = new db();

	$stmt="SELECT COUNT(*) AS darab FROM kk_tag WHERE (kategoria_1=$c OR ((kategoria_2=$c OR kategoria_3=$c OR kategoria_4=$c OR kategoria_5=$c OR kategoria_6=$c OR kategoria_7=$c OR kategoria_8=$c) AND ext=1)) AND jovahagyva=1";

	$result=$mydb->query($stmt);

	$row = mysql_fetch_object($result);

	return "(".$row->darab.")";

}


?>