<?php
include('header.inc.php');


$tablaleiro=adatleiro($leiro_type);

if(!isset($$leiro_type)){

	while (list($key, $val) = each($tablaleiro)) {
		if($tablaleiro[$key]["T_VIS"]=="true"){
			$fields[$key]="true";
		}else{
			$fields[$key]="false";
		}
		if($tablaleiro[$key]["T_ORD"]=="true"){
			$fields[$key."_ORD_"]="true";
			$fields[$key."_BY_"]=$tablaleiro[$key]["T_BY"];

			$orderby.=$key." ".$tablaleiro[$key]["T_BY"].", ";
		}
	}
	reset($tablaleiro);

}else{
	$fields=unserialize(base64_decode($$leiro_type));
	while (list($key, $val) = each($fields)) {
		if($fields[$key."_ORD_"]=="true"){
			$orderby.=$key." ".$fields[$key."_BY_"].", ";
		}
	}
	reset($fields);
}


$orderby=substr($orderby,0,strlen($orderby)-2);
if(strlen($orderby)<>0){
	$orderby=" ORDER BY " . $orderby;
}


$mydb = new db();

$stmt=$query . $orderby;

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

printf("
<B>%s</B>
<TABLE border='1' style='border-collapse: collapse' bordercolor='#CCCCCC' CELLPADDING='5' STYLE='background: #FFFFFF;'>
<TR>", $h3_title);

while (list($key, $val) = each($tablaleiro)) {
	if($fields[$key]=="true"){
		if($fields[$key."_ORD_"]=="true"){
			$by=$fields[$key."_BY_"];
		}
		printf("<TH style='font-size: 11px'>%s&nbsp;%s</TH>\n", $tablaleiro[$key]["TITLE"], $by);
		$by="";
	}
}



printf("
<TH style='font-size: 11px'>Admin</TH>
</TR>
");



while($row = mysql_fetch_object($result)){
	
	printf("<TR>");

	reset($tablaleiro);

	while (list($key, $val) = each($tablaleiro)) {
		if($fields[$key]=="true"){
			if($tablaleiro[$key]["TYPE"]=="RADIO"){
				$opt="OPT" . $row->$key;
				printf("<TD>%s</TD>\n", $tablaleiro[$key][$opt]);
			}else{
				printf("<TD>%s</TD>\n", $row->$key);
			}
		}
	}
	
	printf("<TD><A HREF='%s?id=%s'>szerkeszt</a>", $edit_script, $row->id, $delete_script, $row->id);

}

printf("</TABLE>");

 

?>