Пример #1
0
function quickSortRecursive($arr, $left = 0, $right = NULL)
{
    set_time_limit(1200);
    // when the call is recursive we need to change
    //the array passed to the function yearlier
    static $array = array();
    if ($right == NULL) {
        $array = $arr;
    }
    if ($right == NULL) {
        $right = count($array) - 1;
    }
    //last element of the array
    $i = $left;
    $j = $right;
    $tmp = $array[(int) (($left + $right) / 2)];
    // partion the array in two parts.
    // left from $tmp are with smaller values,
    // right from $tmp are with bigger ones
    do {
        while (substr($array[$i], 10, 8) < substr($tmp, 10, 8)) {
            $i++;
        }
        while (substr($tmp, 10, 8) < substr($array[$j], 10, 8)) {
            $j--;
        }
        // swap elements from the two sides
        if ($i <= $j) {
            $w = $array[$i];
            $array[$i] = $array[$j];
            $array[$j] = $w;
            $i++;
            $j--;
        }
    } while ($i <= $j);
    // divide left side if it is longer the 1 element
    if ($left < $j) {
        quickSortRecursive(NULL, $left, $j);
    }
    // the same with the right side
    if ($i < $right) {
        quickSortRecursive(NULL, $i, $right);
    }
    // when all partitions have one element
    // the array is sorted
    return $array;
}
Пример #2
0
header("Expires: Thu, 29 Oct 2009 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
session_cache_limiter("private_no_expire");
session_start();
$no_of_results = $_GET["no_of_results"];
$no_of_initialresults = $no_of_results + 10;
$value = array();
$k = 0;
for ($i = 0; $i < $no_of_initialresults; $i++) {
    if ($_GET["provgeodist" . $i]) {
        $value[$k] = $_GET["provgeodist" . $i];
        $k++;
    }
}
$value = quickSortRecursive($value);
// If the number of actual facilites found is less than the requested number to find,
// use the number of actual
$no_of_actualresults = $no_of_results;
if ($k < $no_of_results) {
    $no_of_actualresults = $k;
}
//Fetching Actual Data That will be displayed on the screen
for ($i = 0; $i < $no_of_actualresults; $i++) {
    $temp = substr($value[$i], 0, 10);
    $query[$i] = "\tselect longname_of_providers, addressline1, addressline2, city, state, zipcode, phone, fax, \n\t\t\t\t\tmonday_amopen_of_provideraddresses, monday_pmclose_of_provideraddresses, \n\t\t\t\t\ttuesday_amopen_of_provideraddresses, tuesday_pmclose_of_provideraddresses, \n\t\t\t\t\twednesday_amopen_of_provideraddresses, wednesday_pmclose_of_provideraddresses, \n\t\t\t\t\tthursday_amopen_of_provideraddresses, thursday_pmclose_of_provideraddresses, \n\t\t\t\t\tfriday_amopen_of_provideraddresses, friday_pmclose_of_provideraddresses, \n\t\t\t\t\tsaturday_amopen_of_provideraddresses, saturday_pmclose_of_provideraddresses, \n\t\t\t\t\tsunday_amopen_of_provideraddresses, sunday_pmclose_of_provideraddresses, \n\t\t\t\t\tgeneralhours1, generalhours2,\n\t\t\t\t\thippataxonomy, credentialingstatus, FE.Modality, year_manufactured, software, table_weight, \n\t\t\t\t\tfield_strength, CT_Slice, Manufacturer_model, Capabilities, FDA_Certification_num, FDA_EndDate, \n\t\t\t\t\tACR_Effdate, ACR_EndDate, ModalityGroup,MRI_wo, MRI_w, MRI_w_wo, CT_wo, CT_w, CT_w_wo, PET, PET_CT, \n\t\t\t\t\tScreening_Orbit, Medicare_Percentage, ACR_Accredited, F.npi, F.taxid\n\t\t\t\t\tfrom facility as F\n\t\t\t\t\tleft join  facility_rates as FR\n\t\t\t\t\ton  F.provider_key = FR.provider_key\n\t\t\t\t\tleft join facility_equipment as FE  \n\t\t\t\t\ton F.provider_key = FE.provider_key\n\t\t\t\t\tAnd   FE.modality = FR.modality \n\t\t\t\t\tWhere F.provider_key= '{$temp}'";
    $result = mysql_query($query[$i], $database->connection);
    $dbarray[$i] = mysql_fetch_array($result);
}
if (!$dbarray) {
    echo "No Facilities Found within 250 miles of the zipcode entered";