<?php



include ('dbConnect.php');



$idate = explode("/", $_POST['date']);



$date= mysqli_real_escape_string($hookup, $idate[2]."-".$idate[0]."-".$idate[1]);



$ui= $_POST['ui'];



if($ui=="get"){



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



	$usql = "SELECT * FROM `Address Analyzer` WHERE `num` = '$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>".$row['core1']."</num>";

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

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

		$xml.="</item>";

	}

	

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

	echo $xml;

	

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





	$usql = "SELECT * FROM `Address Analyzer` ORDER BY `num` 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.="<num>".$row['num']."</num>";

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

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

		$xml.="</item>";

	}

	

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

	echo $xml;

	

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

		

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



	$usql = "SELECT * FROM `Address Analyzer` WHERE `num` = '$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.="<short><![CDATA[".$row['short']."]]></short>";

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

		$xml.="</item>";

	}

	

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

	echo $xml;

	

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



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

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

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

	

	$sql = "UPDATE `Address Analyzer` SET `desc` = '$desc' WHERE `num` = '$num'";

	

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

		$return = "success";

		echo $return; 

	}else{

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

		echo $return; 

	 }

	 

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



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

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

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

	

	$sql = "INSERT INTO `Address Analyzer` (`ID`, `num`, `desc`, `language` ) VALUES ('', '$num' , '$desc', '0')";

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

	$used_id = "<result>".mysqli_insert_id($hookup)."</result>";

	if($result){

		

		$return = $used_id;

		echo $return; 

	}else{

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

		echo $return; 

	 }

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



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

	

	$sql = "DELETE FROM `Address Analyzer` WHERE `ID` = '$id'";

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

	$used_id = "<result>".mysqli_insert_id($hookup)."</result>";

	if($result){

		

		$return = "success";

		echo $return; 

	}else{

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

		echo $return; 

	 }

}



?>