<?php require_once('Connections/conn_newland.php'); ?>
<?php
// Load the XML classes
require_once('includes/XMLExport/XMLExport.php');

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_conn_newland, $conn_newland);
$query_rs_countryDetail = "SELECT countryID, regionName, countryName, population, country_currency, `description`, imageURL, imageALT FROM tbl_country, tbl_region WHERE tbl_region.regionID = tbl_country.region ORDER BY countryName ASC";
$rs_countryDetail = mysql_query($query_rs_countryDetail, $conn_newland) or die(mysql_error());
$row_rs_countryDetail = mysql_fetch_assoc($rs_countryDetail);
$totalRows_rs_countryDetail = mysql_num_rows($rs_countryDetail);

// Begin XMLExport rs_countryDetail
$xmlExportObj = new XMLExport();
$xmlExportObj->setRecordset($rs_countryDetail);
$xmlExportObj->addColumn("countryID", "countryID");
$xmlExportObj->addColumn("regionName", "region");
$xmlExportObj->addColumn("countryName", "countryName");
$xmlExportObj->addColumn("population", "population");
$xmlExportObj->addColumn("country_currency", "country_currency");
$xmlExportObj->addColumn("description", "description");
$xmlExportObj->addColumn("imageURL", "imageURL");
$xmlExportObj->addColumn("imageALT", "imageALT");
$xmlExportObj->setMaxRecords("ALL");
$xmlExportObj->setDBEncoding("UTF-8");
$xmlExportObj->setXMLEncoding("UTF-8");
$xmlExportObj->setXMLFormat("NODES");
$xmlExportObj->setRootNode("countries");
$xmlExportObj->setRowNode("country");
$xmlExportObj->Execute();
// End XMLExport rs_countryDetail

mysql_free_result($rs_countryDetail);
?>