<?php
	require_once '../../autoload.php';

	$type 	= -1;

	if ( isset($_GET['type']) )
		$type	= $_GET['type'];

	$type = ($type == -1)? "" : $type;
		
	$conn = get_dbconnection();
	
	$answer = "<results>";
	
	if ( $conn )
	{
		$sql = "select id,name from survey_type order by name";

		if ( $query = pg_query($conn,$sql) )
		{
			while ( $row = pg_fetch_row($query) )
			{
				$answer .= "<survey_type id=\"".$row[0]."\" name=\"".$row[1]."\"></survey_type>";
			}
		}
	}
	
	$answer .= "</results>";

	header ('Content-type: text/xml' );
	
	echo $answer;
?>