You are coming from md1network.com in zip code 20146

Search Results

global $post;
$term = $_GET['term'];
$specialty = $_GET['specialty'];
$city = $_GET['city'];
$state = $_GET['state'];

$querylist_string = “Searching “;
$qry = “SELECT ID FROM `wp_posts` WHERE “;
$qry_ext = “”;
$query_concat = array();

if ($term <> “”) {
$querylist_string .= “for ” . $term;
$qry_ext .= ” AND ID IN (SELECT ID FROM wp_posts WHERE post_title LIKE ‘%” . $term . “%’ AND post_type = ‘post’ AND post_status = ‘publish’)”;
}
if ($specialty <> “”) {
// Get the name of the specialty
$catqry = “SELECT name FROM wp_terms WHERE term_id = ‘” . $specialty . “‘ LIMIT 1″;
$cat_results = mysql_query($catqry);
$cat_rowcount = mysql_num_rows($cat_results);
if ($cat_rowcount > 0) {
$cat_row = mysql_fetch_row($cat_results);
$cat_name = $cat_row[0];

}
$querylist_string .= ” in ” . $cat_name . ” category “;
$qry_ext .= ” AND ID IN (SELECT a.object_id FROM wp_term_relationships a, wp_term_taxonomy b WHERE a.term_taxonomy_id = b.term_taxonomy_id AND b.term_id = ‘” . $specialty . “‘)”;
}
if ($city <> “”) {
$querylist_string .= ” in ” . $city;
$qry_ext .= ” AND ID IN (SELECT post_id FROM wp_postmeta WHERE meta_key = ‘_city’ AND meta_value = ‘” . $city . “‘)”;
}
if ($state <> “”) {
$querylist_string .= “, ” . $state;
$qry_ext .= ” AND ID IN (SELECT post_id FROM wp_postmeta WHERE meta_key = ‘_state’ AND meta_value = ‘” . $state . “‘)”;
}

echo $querylist_string . “
“;
if (substr($qry_ext, 0, 5) == ” AND “) $qry_ext = substr($qry_ext, 5, strlen($qry_ext));

// Have to get posts with raw query.

$qry = $qry . $qry_ext . ” AND post_type = ‘post’ AND post_status = ‘publish’”;
$select_results = mysql_query($qry);
if (!$select_results) echo mysql_error();
$select_rowcount = mysql_num_rows($select_results);
echo “Found ” . $select_rowcount . ” results.”;

// Once you have the posts just loops trough them as you would do usually
if ($select_rowcount > 0) {
while ($select_row = mysql_fetch_row($select_results)) {
$post_id = $select_row[0];
$post = get_post($post_id);
setup_postdata($post);

echo ”

  • ID) . “\”>” . $post->post_title . “
    ” . get_post_meta(get_the_ID(), ‘_address1′, true) . ” in ” . get_post_meta(get_the_ID(), ‘_city’, true) . “, ” . get_post_meta(get_the_ID(), ‘_state’, true) . “
  • “;
    }

    }
    ?>

    MD1 Network provided by ActiveMD Medical Marketing