<html>
<head>
<title>
test
</title>
</head>
<body>

<?php

	$db_link = mysqli_connect('localhost', 'katrinstatus', 'pjX3nVWhnQNt7nP8', 'katrinstatus');

	$adei_table = array( 'dcct', 'dcct', 'dcct', 'dcct' );
	$adei_column = array( 'adei_value', 'adei_ideal', 'adei_status', 'adei_power' );

	for ($id = 0; $id < sizeof($adei_table); $id++)
	{
		$sql = "SELECT * FROM " . $adei_table[$id];

		$db_erg = mysqli_query($db_link, $sql) or die("Anfrage fehlgeschlagen: " . mysqli_error());

		while ($row = mysqli_fetch_array($db_erg, MYSQL_ASSOC))
		{
			echo $row[$adei_column[$id]];
		}

		mysqli_free_result($db_erg);
	}

	






/*
	$username = 'katrin';
	$password = 'neutrino';
	$context = stream_context_create(array(
		'http' => array(
			'header'  => "Authorization: Basic " . base64_encode("$username:$password")
		)
	));


	for ($id = 0; $id < sizeof($adeiChannel); $id++)
	{
		$adeiChannels = "";
		for ($id2 = 0; $id2 < sizeof($adeiChannel[$id]); $id2++)
		{
			$adeiChannels = $adeiChannels . $adeiChannel[$id][$id2] . ",";
		}
		$adeiChannels = substr($adeiChannels, 0, strlen($adeiChannels) - 1);

      		$fileip = file_get_contents("http://katrin.kit.edu/adei/services/getdata.php?db_server=virtual&db_name=srctree&db_group=-3&control_group=-3&virtual=srctree&srctree=" . $adeiChannels . "&window=60&format=csv", false, $context);
		//echo $fileip . "<br>";

		for ($id2 = sizeof($adeiChannel[$id]) - 1 ; $id2 > -1; $id2--)
		{
			$pos = strrpos($fileip, ",");
			$adeiValue[$id][$id2] = floatval(substr($fileip, $pos + 2));
			$fileip = substr($fileip, 0, $pos);
			//echo $id . "," . $id2 . "," . $adeiValue[$id][$id2] . "<br>";
		}
	}


*/

/*
	// ÄNDERN

	$sql = "UPDATE sds SET actual = 0, ideal = 0 WHERE system = 'lfcs' AND id = 2";

	$db_erg = mysqli_query($db_link, $sql) or die("Anfrage fehlgeschlagen: " . mysqli_error());
*/
/*
	// LESEN

	$sql = "SELECT * FROM dcct_current WHERE id = 'lfcs 2'";

	$db_erg = mysqli_query($db_link, $sql) or die("Anfrage fehlgeschlagen: " . mysqli_error());

	while ($zeile = mysqli_fetch_array($db_erg, MYSQL_ASSOC))
	{
		echo $zeile['ideal'];
	}

	mysqli_free_result($db_erg);
*/
?>

</body>
</html>