$height) {
$limiter = “height=’$height'”;
} else {
$limiter = “width=’$width'”;
}
return $limiter;
}

function adp_Price($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘_features_1_col1_1’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_Availability($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘_features_1_col1_3’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_County($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘_features_1_col1_2’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_Acreage($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘_features_1_col2_1’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_PriceAcre($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘_features_1_col2_2’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_ShortDesc($id) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘Short Desc’ LIMIT 1″));
return $row[‘meta_value’];
}

function adp_Featured($id, $width, $height) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘featured’ LIMIT 1″));
return ““;
}

function adp_Map1($id, $width, $height) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘map1’ LIMIT 1″));
return ““;
}

function adp_Map2($id, $width, $height) {
$row = mysql_fetch_assoc(mysql_query(“SELECT * FROM wp_postmeta WHERE post_id = ‘”.$id.”‘ AND meta_key = ‘map2’ LIMIT 1″));
return ““;
}

$wp_DB = mysql_connect(“localhost”, “galand_wpmod”, “wordpressmod”) or die (“unable to connect to database 01: ” . mysql_error());
mysql_select_db(“galand_wrdp1”, $wp_DB) or die (“unable to connect to database 02: ” . mysql_error());
$sort_by = $_GET[‘order’];

if($sort_by == “asc”) {
$next_sort_by = “desc”;
} else {
$next_sort_by = “asc”;
}

$query = “SELECT * FROM wp_posts WHERE post_status = ‘publish’ AND post_type = ‘post'”;
if($_GET[“sort”] == “acreage”) {
$query = “SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id WHERE wp_posts.post_status = ‘publish’ AND wp_posts.post_type = ‘post’ AND wp_postmeta.meta_key = ‘_features_1_col2_1’ ORDER BY wp_postmeta.meta_value “.$sort_by;
}

if($_GET[“sort”] == “county”) {
$query = “SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id WHERE wp_posts.post_status = ‘publish’ AND wp_posts.post_type = ‘post’ AND wp_postmeta.meta_key = ‘_features_1_col1_2’ ORDER BY wp_postmeta.meta_value “.$sort_by;
}

if($_GET[“sort”] == “acreage”) {
/*
$query = “SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id WHERE wp_posts.post_status = ‘publish’ AND wp_posts.post_type = ‘post’ AND wp_postmeta.meta_key = ‘_features_1_col2_1’ ORDER BY wp_postmeta.meta_value “.$sort_by;
*/
$query = “SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id WHERE wp_posts.post_status = ‘publish’ AND wp_posts.post_type = ‘post’ AND wp_postmeta.meta_key = ‘_features_1_col2_1’ ORDER BY cast(replace(TRIM(LEADING ‘$’ FROM wp_postmeta.meta_value),’,’,”) AS UNSIGNED) “.$sort_by;
}
if($_GET[“sort”] == “price”) {
$query = “SELECT * FROM wp_posts JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id WHERE wp_posts.post_status = ‘publish’ AND wp_posts.post_type = ‘post’ AND wp_postmeta.meta_key = ‘_features_1_col1_1’ ORDER BY cast(replace(TRIM(LEADING ‘$’ FROM wp_postmeta.meta_value),’,’,”) AS UNSIGNED) “.$sort_by;
}
$queryResult = mysql_query($query);

echo ‘

‘;

while($row = mysql_fetch_assoc($queryResult)) {
$id = $row[‘ID’];
$title = $row[‘post_title’];
$content = $row[‘post_content’];

if($content == “”) { continue; }

echo ‘

‘;

}
echo ‘

Name Short Description County Acreage Price Picture
‘.$title.’ ‘.adp_ShortDesc($id).’ ‘.adp_County($id).’ ‘.adp_Acreage($id).’ $’.adp_Price($id).’ ‘./*adp_Featured($id, 100, 100)*/get_the_post_thumbnail($id, ‘thumbnail’).’

‘;
?>