<?php



include ('dbConnect.php');



$num = intval($_POST["num"]);



$ui= $_POST['ui'];



if($ui=="get"){

	$usql = "SELECT * FROM `RelationshipCompatability` WHERE `num_one` = '$num'";

	$result = mysqli_query($hookup, $usql);

	$cnt=0;

	$xml="<xml><data>";

	//$row = mysqli_fetch_assoc($result);

	while($row = mysqli_fetch_assoc($result)) {

		$xml.="<item><id>".$row['ID']."</id>";

		$xml.="<num_one>".$row['num_one']."</num_one>";

		$xml.="<num_two>".$row['num_two']."</num_two>";

		$xml.="<title><![CDATA[".$row['title']."]]></title>";

		$xml.="<desc><![CDATA[".$row['desc']."]]></desc>";

		$xml.="</item>";

	}

	

	$xml.="</data></xml>";

	echo $xml;

	

}else if($ui=="update"){



$id = intval($_POST['id']);

$title = mysqli_real_escape_string($hookup, $_POST['title']);

$desc = mysqli_real_escape_string($hookup, $_POST['desc']);

	

	$sql = "UPDATE `RelationshipCompatability` SET `title` = '$title', `desc` = '$desc' WHERE `ID` = '$id'";

	

	if(mysqli_query($hookup, $sql)){

		$return = "success";

		echo $return; 

	}else{

		$return = "error=" . $type. " / ". mysqli_error($hookup);

		echo $return; 

	 }

	 

}else if($ui=="get_forecast"){

	$usql = "SELECT * FROM `RelationshipForecast` WHERE `num_one` = '$num'";

	$result = mysqli_query($hookup, $usql);

	$cnt=0;

	$xml="<xml><data>";

	//$row = mysqli_fetch_assoc($result);

	while($row = mysqli_fetch_assoc($result)) {

		$xml.="<item><id>".$row['ID']."</id>";

		$xml.="<num_one>".$row['num_one']."</num_one>";

		$xml.="<num_two>".$row['num_two']."</num_two>";

		$xml.="<title><![CDATA[".$row['title']."]]></title>";

		$xml.="<desc><![CDATA[".$row['desc']."]]></desc>";

		$xml.="</item>";

	}

	

	$xml.="</data></xml>";

	echo $xml;

	

}else if($ui=="update_forecast"){



$id = intval($_POST['id']);

$title = mysqli_real_escape_string($hookup, $_POST['title']);

$desc = mysqli_real_escape_string($hookup, $_POST['desc']);

	

	$sql = "UPDATE `RelationshipForecast` SET `title` = '$title', `desc` = '$desc' WHERE `ID` = '$id'";

	

	if(mysqli_query($hookup, $sql)){

		$return = "success";

		echo $return; 

	}else{

		$return = "error=" . $type. " / ". mysqli_error($hookup);

		echo $return; 

	 }

	 

}



?>