function getActivityCombo()
{
    // Select all the rows in the categories table marked as a persistent activity
    $query = "SELECT * FROM categories WHERE is_per_activity = 1 ORDER BY name ASC";
    echo executePDO(false, $query, array(), function ($PDO_prep) {
        $spaces = "                ";
        $select = "<select name='activity'>\n";
        $select = $select . "{$spaces}  <option value='no-selection' id='no-activity'>Add Activity</option>\n";
        while ($row = $PDO_prep->fetch(PDO::FETCH_ASSOC)) {
            $select = $select . "{$spaces}  <option value='{$row['path']}'>{$row['name']}</option>\n";
        }
        $select = $select . "{$spaces}</select>\n";
        return $select;
    });
}
function getVenueCombo()
{
    // Select all the rows in the categories table marked as a venue
    $query = "SELECT * FROM categories WHERE is_venue = 1 ORDER BY name ASC";
    echo executePDO(false, $query, array(), function ($PDO_prep) {
        $spaces = "                ";
        $select = "<select id='venue-type' name='venue-type' style='width:100%;'>\n";
        $select = $select . "{$spaces}  <option value='no-selection' id='no-cat'>Select Category</option>\n";
        while ($row = $PDO_prep->fetch(PDO::FETCH_ASSOC)) {
            $select = $select . "{$spaces}  <option value='{$row['path']}'>{$row['name']}</option>\n";
        }
        $select = $select . "{$spaces}</select>\n";
        return $select;
    });
}
// Add GEO Clause
if ($catClause != "" || $dateClause != "") {
    $query = $query . " AND ";
    $query = $query . "(venues.lat > :start_lat AND venues.lat < :end_lat AND venues.lng > :start_lng AND venues.lng < :end_lng)";
    $parm_vals[':start_lat'] = $startLat;
    $parm_vals[':end_lat'] = $endLat;
    $parm_vals[':start_lng'] = $startLng;
    $parm_vals[':end_lng'] = $endLng;
}
// Close Where parenthesis (opened before adding clauses) and LIMIT Clause
$query = "{$query} ) LIMIT :first_rec ,{$NUM_EVENTS}";
$parm_vals[':first_rec'] = $page * $NUM_EVENTS;
echo header("Content-type: text/json");
try {
    $results = executePDO(false, $query, $parm_vals, function ($PDO_prep) {
        $json_record_format = '{event_name : "%s", venue_name : "%s", performer_name : "%s", event_format_id : %d, persistent : %s, lat : %f, lon : %f, type : "%s", date : "%s", time : "%s"}';
        $json_record_array = array();
        $count = 0;
        // Iterate through the rows
        while ($row = $PDO_prep->fetch(PDO::FETCH_ASSOC)) {
            // check the documentation for the other options here
            $json_record_array[$count] = sprintf($json_record_format, str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['EVENT_NAME'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['VENUE_NAME'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['performer_id'])), $row['event_format_id'], $row['persistent'], $row['lat'], $row['lng'], $row['type'], $row['date'], $row['time']);
            $count++;
        }
        return $json_record_array;
    });
    echo "[" . join(",", $results) . "]";
} catch (Execution $e) {
    //@todo:  need to handle this error case in the browser
    echo "{ error : " . $e->getMessage() . "}";
}
$query = "SELECT venues.*, categories.name AS type FROM venues, categories WHERE venues.name LIKE :searchString AND lat BETWEEN :startLat AND :endLat  AND lng BETWEEN :startLng AND :endLng AND venues.type = categories.path";
# Add Venue Name Search String
$searchString = $_GET["searchString"];
$startLat = $_GET["startLat"];
$endLat = $_GET["endLat"];
$startLng = $_GET["startLng"];
$endLng = $_GET["endLng"];
$parm_vals['searchString'] = "%" . $searchString . "%";
$parm_vals['startLat'] = $startLat;
$parm_vals['endLat'] = $endLat;
$parm_vals['startLng'] = $startLng;
$parm_vals['endLng'] = $endLng;
echo header("Content-type: text/json");
try {
    $results = executePDO(false, $query, $parm_vals, function ($PDO_prep) {
        $json_record_format = '{venueId : "%s", venueName : "%s", address : "%s", phone : "%s", description : "%s", lat : %f, lng : %f, type : "%s"}';
        $json_record_array = array();
        $count = 0;
        // Iterate through the rows
        while ($row = $PDO_prep->fetch(PDO::FETCH_ASSOC)) {
            // check the documentation for the other options here
            $json_record_array[$count] = sprintf($json_record_format, str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['id'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['name'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['address'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['phone'])), str_replace('"', "&rdquo;", str_replace("'", "&rsquo;", $row['description'])), $row['lat'], $row['lng'], $row['type']);
            $count++;
        }
        return $json_record_array;
    });
    echo "[" . join(",", $results) . "]";
} catch (Execution $e) {
    //@todo:  need to handle this error case in the browser
    echo "{ error : " . $e->getMessage() . "}";
}