<<? echo "?";?>xml version="1.0" encoding="UTF-8"<? echo "?";?>>
<rss version="2.0">
<channel>
<title>New properties on pattaya City</title>
<description>Lastest properties listing on pattaya and all area around Pattaya. Get your update now !</description>
<link>http://www.towncountryproperty.com/</link>
<copyright>Copyright 2007 www.towncountryproperty.com</copyright>

<image>
<title>Real Estate - Property  on Pattaya</title>
<url>http://www.towncountryproperty.com/img/rss-logo.gif</url>
<link>http://www.towncountryproperty.com</link>
</image>

<?
include('config.php');

//gen Area
$strSQL="SELECT AreaCode,AreaName FROM tbareacode;";
$rt = mysql_query($strSQL) ;					
while ($rst=mysql_fetch_array($rt)){	
	$area[$rst["AreaCode"]]=$rst["AreaName"];					
}		
	
	
if ($s) $wh=" where title like '%$s%' or contents like '%$s%' or tag like '%$s%' ";
$limit=($_REQUEST['limit']) ? $_REQUEST['limit'] : "10 ";

	$sql="select propertyid, property_type,property_code, area_code, sale_price, rent_price, 
	 bedroom, bathroom, posttime from tbproperties order by posttime DESC limit 0,$limit";
	$res=mysql_query($sql);
	while ($rs = mysql_fetch_array($res)) {
		unset($desc); unset($Price);
	  	unset($PicName);

		$PCode=$rs['property_code'];
		$PicDir="http://www.towncountryproperty.com/$PicPath";
		$PicName = "$PicDir/$PCode/$PCode-1S.jpg";	
		$Area=$area[$rs['area_code']];
		$Ptype=$rs['property_type'];
		
		if ($rs['sale_price']>0) {
			$Price=number_format($rs['sale_price'],0)." baht";
			$Pfor=" sale ";
		}else if ($rs['sale_price']>0 and $rs['rent_price']>0) {
			$Price="sale: " . number_format($rs['sale_price'],0)." baht ,   rental: ".number_format($rs['rent_price'],0)." baht/month";
			$Pfor=" sale or rental ";
		}else{
			$Price=number_format($rs['rent_price'],0)." baht/month";
			$Pfor=" rental ";			
		}
		if ($rs['bedroom']) $desc=$rs['bedroom']." bedrooms, ";
		if ($rs['bathroom']) $desc=$desc.$rs['bathroom']." bathtooms, ";
		
		$desc=$desc."<br/>" .$rs['description'];
		
		$alt="Newest $Area $Ptype for $Pfor ";	
		$title="$Ptype for $Pfor on $Area";		
	    $time=@strftime( "%a, %d %b %Y %T %Z" , $rs['timestamp']); 
		$img="<img src='$PicName' alt='$alt' border='0' width='100' height='75'  align='left' hspace='10' />";
		$lnk="http://www.towncountryproperty.com/details.php?PropertyCode=".$PCode;
		
  $format=1;  if($_REQUEST['format']!="") $format=$_REQUEST['format'];
  $len=($_REQUEST['len'])? $_REQUEST['len'] : 250 ;    

	if ($format){
	  $contents="$img<a href='$lnk'><b>$title</b></a><br />$Price<br />$desc";
	}else{
	  $contents="$img<br />$title <br /> $Price<br />$desc";  
  }
  $title=htmlentities($title);  
  $contents=htmlentities($contents);  

?>
     <item>
        <title><? echo "$title"?></title>
        <description><? echo $contents?></description>
        <link><? echo $lnk?></link>
        <pubDate><? echo $time?></pubDate>
     </item>  
<? } // end while?>  

</channel>
</rss>