<?php
if ($aangemeld == "ja")
{
	$query = mysql_query("SELECT naam FROM members WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= last_online;");
	$tellen = mysql_num_rows($query);
	$query2 = mysql_query("SELECT naam FROM members WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= last_online3;");
	$tellen2 = mysql_num_rows($query2);
	if (!ISSET($wie_online))
	{
		if ($tellen == 1)
		{
			$online_text_1 = "is";
			$online_text_2 = "";
		}
		else
		{
			$online_text_1 = "zijn";
			$online_text_2 = "'s";
		}
		if ($tellen2 == 1)
		{
			$online_text_3 = "";
			$online_text_4 = "";
		}
		else
		{
			$online_text_3 = "'s";
			$online_text_4 = "en";
		}
		echo "Er ".$online_text_1." <a href='wie.php'>".$tellen."</a> Jabbo".$online_text_2." online.<br>";
		echo "Er wacht".$online_text_4." ".$tellen2." Jabbo".$online_text_3." om binnen te mogen.";
		
	}
	else
	{
		$vioolgeschal = $tellen - 1;
		$i = 0;
		$plus = "";
		while($rij = mysql_fetch_array($query))
		{
			$functie = halen("SELECT functie FROM members WHERE naam='".$rij['naam']."';");
			$voor = "";
			$achter = "";
			if ($functie != "jabbo")
			{
				$voor = "<b>";
				$achter = "</b>";
			}
			if ($functie == "manager")
			{
				$voor .= "<font color='red'><u>";
				$achter .= "</u></font>";
			}
			if ($functie == "staff")
			{
				$voor .= "<font color='blue'>";
				$achter .= "</font>";
			}
			if ($tellen == "0")
			{
				echo "Er is niemand online!";
			}
			elseif ($tellen == "1")
			{
				echo "Alleen ";
			}
			if ($rij['naam'] == $_SESSION['naam'])
			{
				echo $voor."jij".$achter;
				$plus = " bent";
			}
			elseif ($tellen == "1")
			{
				echo $voor.$rij['naam'].$achter." is";
			}
			else
			{
				echo $voor.$rij['naam'].$achter;
			}
			$i++;
			if ($i != $tellen)
			{
				if ($vioolgeschal == $i)
				{
					echo " en ";
				}
				else
				{
					echo ", ";
				}
			}
		}
		if ($tellen == 1)
		{
			echo $plus." online";
		}
		elseif ($tellen >= "1")
		{
			echo " zijn online";
		}
	}
}
?>