<html>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<body bgcolor="white">
<?php
	include("scripts/sqlinfo.inc");
	include("cdbmysql.php");

	mysql_connect($host, $user, $pass);
	mysql_selectdb("pyrot");

	$db = new CDBMySQL($host, $user, $pass, "pyrot");

	$ymd = date("Ymd", time());
	
	if (!$all) {
		$query = "select * from event where datum+0 >= " . $ymd . " order by datum";
		$result=mysql_query($query);
	} else {
		$result=mysql_query("select * from event where datum+0 <= " . $ymd . " order by datum desc limit 10");
	}

	if ($r=mysql_fetch_array($result)){
		printf("<center><table width=400 border=0 cellspacing=0 cellpadding=0><tr><td>
				<a href=\"events.php?all=0\"><b>Kommande skjutningar</b></a>
			</td><td valign=top align=right><a href=\"events.php?all=1\">
				<b>10 senaste skjutningarna</b></a></td></tr>
				<tr><td><br></td></tr>
				<tr><td colspan=2><span class=\"header1\">Skjutningar</span></td></tr>");
		do {
			printf("<tr><td colspan=2><b>%s %s, %s</b></td></tr>
				<tr><td colspan=2>Plats: %s</td></tr>
				<tr><td colspan=2>Beställare: %s</td></tr>
				<tr><td colspan=2>Länk: %s</td></tr>
				"
				,$r["datum"], $r["tid"], $r["rubrik"], $r["plats"], $r["customer"], $r["eventlink"]);
			if($r["chief"]!="0") {
				$db->Query("SELECT namn FROM medlemmar WHERE col_id = " . $r["chief"]);
				$cname = "";
				if ($db->ReadRow()) {
					$cname = $db->RowData["namn"];
				}
				printf("<tr><td>Ansvarig: <a href=\"members.php?id=%s\">%s</a>
					<tr><td colspan=2>%s<hr></td></tr>",
				 	$r["chief"], $cname, $r["info"] );
			} else {
				printf("<tr><td>Ansvarig: Ingen &auml;nnu<tr><td colspan=2>%s<hr></td></tr>",
				 	$r["info"] );
			}
		} while($r=mysql_fetch_array($result));
		printf("</table></center>");
	} else {
		printf("Inga skjutningar på gång");
	}

	$db->Close();
?>
</body>
</html>
