<?php
function getCategories()
{
	global $IMAGES_DIR;
	
	# on ne prend toutes la categories (sauf la root)
	$date = date("Y-m-d H:i:s", my_local_time());
	$categories=main_db_query("SELECT Categories.* FROM Matchs".
	" LEFT JOIN Categories ON Categories.CategoryId=Matchs.Category ".
	" WHERE Categories.ShowTime<'".$date."' AND Categories.EndTime>'".$date."'".
	" AND Matchs.ShowTime<'".$date."' AND Matchs.Date>'".$date."' AND Result='0'".
	" GROUP BY Matchs.Category".
	" ORDER BY Matchs.Date ASC");
	
	# on commence à 1 histoire de matcher entre les CategoryId et les indices
	$r=1;
	while($category = db_fetch_array($categories))
	{
		$tabCategories[$r] = $category;
		$r++;
		$categoriesShowed .= "'".$category[CategoryId]."',";
	}
	
	$categories=main_db_query("SELECT * FROM Categories".
	" WHERE Categories.ShowTime<'".$date."' AND Categories.EndTime>'".$date."'".
	" AND CategoryId NOT IN (".$categoriesShowed."'')");
	
	while($category = db_fetch_array($categories))
	{
		$tabCategories[$r] = $category;
		$r++;
	}
	
	return $tabCategories;
}
?>