function distance_between_postcodes($zipone, $ziptwo, $unit)
{
    if ($zipone == null) {
        die;
    }
    $db_ecalendar = ECalendarDb::inst();
    $sql_query = "SELECT * FROM uk_postcodes WHERE postcode=?";
    $sql_result1 = $db_ecalendar->query($sql_query, $zipone);
    if (!$sql_result1) {
        die('Could not query1:');
    }
    $ziponedata = $sql_result1->fetch(PDO::FETCH_GROUP);
    $sql_query = "SELECT * FROM uk_postcodes WHERE postcode=?";
    $sql_result2 = $db_ecalendar->query($sql_query, $ziptwo);
    if (!$sql_result2) {
        die('Could not query1:');
    }
    $ziptwodata = $sql_result2->fetch(PDO::FETCH_GROUP);
    $distancebetween = distance55($ziponedata[3], $ziponedata[4], $ziptwodata[3], $ziptwodata[4], $unit);
    return $distancebetween;
}
}
//current days
for ($i = 1; $i <= $day_count; $i++) {
    $todayDate = date("l jS F Y", mktime(0, 0, 0, $showmonth, $i, $showyear));
    if ($i < 10) {
        $j = "0{$i}";
    } else {
        $j = $i;
    }
    if ($showmonth < 10) {
        $doublemonth = "0{$showmonth}";
    } else {
        $doublemonth = $showmonth;
    }
    $date = $showyear . '/' . $doublemonth . '/' . $j;
    $db_ecalendar = ECalendarDb::inst();
    $sql_query = "SELECT id FROM events WHERE event_date=? ";
    $sql_result = $db_ecalendar->query($sql_query, $date);
    if ($sql_result->rowCount() > 0) {
        $event = "<div class='event-day' title='{$date}' id='{$todayDate}' onClick='javascript:show_details(this.title, this.id);'>";
    } else {
        $event = "<div class='cal-day' title='{$date}'>";
    }
    echo $event;
    echo '<div class="day-heading">' . $i . '</div>';
    if ($sql_result->rowCount() != 0) {
        echo '<div class="openings">Click for details</div>';
    }
    echo '</div>';
}
//post days