<?php



include ('dbConnect.php');



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



$ui= $_POST['ui'];



if($ui=="get"){

	$usql = "SELECT * FROM `Dualities` WHERE `year` = '$year'";

	$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.="<essence>".$row['essence']."</essence>";

		$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 `Dualities` 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; 

	 }

	 

}



?>