<?php

//created by debnath for featured listing


function featured_display_listing($imgfolder)
{
	
       
		$st='';
		$sql= " SELECT distinct rs.id as id , rs.beds,rs.description ,
		rs.baths, DATE_FORMAT(rs.listdate,'%a, %b %d, %Y ') as listdate, 
		ltype.name as listing_type, property_type.name as property_type, 
		country.name as country, city.name as city, area.name as area 
		FROM realestate rs 
		LEFT JOIN single_field_table ltype ON(ltype.id=rs.listing_type) 
		LEFT JOIN single_field_table property_type ON(property_type.id=rs.property_type)
		LEFT JOIN single_field_table country ON(country.id=rs.country) 
		LEFT JOIN single_field_table city ON(city.id=rs.city) 
		LEFT JOIN single_field_table area ON(area.id=rs.area) 
		WHERE rs.featured ='y' ORDER BY rs.id desc LIMIT 0,5";
	 		$result=mysql_query($sql);
  			while ($row = mysql_fetch_array($result))
			{			
			
			 extract($row); 
			// $luink_url="new-real-estate-".$city."-".$id.".html";
			 $luink_url="details.php?id=".$id;
			 $imgname=get_field_name("realimages","imgname","real_id",$id);
			$st.='<div id=conboxbig><h1></h1><h4>'.img_resize_and_display($imgfolder,$imgname,85,85,85,'').'</h4><h3>'.$area.",".$city."</h3><p>". $description.",".$beds.",". $baths.'</p><h2><a href='.$luink_url.'>View Details ></a></h2></div><br>';
            }
			return $st;
}

function  img_resize_and_display($src,$imgname,$reqwidth,$reqheight,$target,$alt='' )
{
$imgpath=$src.$imgname;

if(file_exists($imgpath) &&  strlen($imgname)>3)
{
$mysock = getimagesize($imgpath);
$image='<a href="'.$imgpath.'" target="_blank" >'; 
$image .= '<img src="' . $imgpath . '"   alt="' .$alt . '"';
if($mysock[0] > $reqwidth || $mysock[1] > $reqheight)
{
$image .= imageResize($reqwidth, $reqheight, $target);

} 
	 
 
	// if(tep_not_null($target))
	  //$image .= $target;
	$image.=' border="0"';
	 

    $image .= ' >'.'</a>';

    return $image;
	} 
	else return "";


}
?>