<?php


include ('dbConnect.php');



$ui= $_POST['ui'];



if($ui=="get"){





	$usql = "SELECT * FROM `Chapters` ORDER BY `ID` ASC";

	

	$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.="<ref><![CDATA[".$row['reference']."]]></ref>";

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

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

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

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

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

		$xml.="</item>";

	}

	

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

	echo $xml;

	

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



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

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

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

	

	$sql = "UPDATE `Chapters` 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; 

	 }

	 

}



?>