<!-- **************************** ROZLISENIA A KATEGORIE *****************************-->
		<div id="melodia_div">
	  	<table width="100%">
		  <tr>
		    <td width="50%" valign="top">
		      <?php
		      
		      	$cdata = array();
		      	$types = array();
		      	$query = "SELECT genre, file FROM mobile_melody";
		      	$data = $dba->GetArray($query);
		      	foreach($data as $melody)
		      	{
		      		$type = strtoupper(substr($melody['file'], strlen($melody['file'])-3, 3));
		      		if(!in_array($type, $types))
		      		{
		      			$types[] = $type;
		      		}
		      		if(array_key_exists($melody['genre'], $cdata))
		      		{
		      			if(array_key_exists($type, $cdata[$melody['genre']]))
		      			{
		      				$cdata[$melody['genre']][$type]++;
		      			}
		      			else 
		      			{
		      				$cdata[$melody['genre']][$type] = 1;
		      			}
		      		}
		      		else 
		      		{
		      			$cdata[$melody['genre']][$type] = 1;
		      		}
		      	}
//		      	dump($cdata);
		      	
		      	echo "<table id=\"stats_table01\" cellspacing=\"0\" cellpadding=\"0\">";
				echo "<tr>";
				echo "<td>&nbsp;</td>";
				foreach($types as $type) echo "<td align=\"center\"><b>".$type."</b></td>";
				echo "<td align=\"center\"><b>spolu</b></td>";
				echo "</tr>";
				$sum_types = array();
				$total = 0;
				foreach($cdata as $genre => $v)
				{
					echo "<tr id=\"stats_table01\"><td><b>".$melody_genres[$genre]."</b></td>";
					$sum = 0;
					foreach($types as $type)
					{
						echo "<td width=\"11%\" align=\"center\">";
						if(isset($v[$type]))
						{
							echo $v[$type];
							$sum += $v[$type];
							if(array_key_exists($type, $sum_types))
							{
								$sum_types[$type] += $v[$type];
							}
							else 
							{
								$sum_types[$type] = $v[$type];
							}
						}
						else 
						{
							echo 0;
						}
						echo "</td>";
					}
					echo "<td align=\"center\"><b>".$sum."</b></td>";
					$total += $sum;
					echo "</tr>";
				}
				echo "<tr><td><b>spolu:</b></td>";
				foreach($types as $type) echo "<td align=\"center\"><b>".$sum_types[$type]."</b></td>";
				echo "<td align=\"center\" id=\"red\"><b>$total<b/></td>";
				echo "</tr>";
				echo "</table>";
		      	
				unset($cdata);
				unset($sum_types);
		      ?>
		    </td>
		  </tr>	  
	  	</table>
		</div>