// Include required
require("./etc/ru.cfg");
if(!class_exists('ps_db')) {
require($base_dir . "db/db.php");
}
//echo $cc_age . "
“;
//echo $age . “
“;
//echo $resources . “
“;
//echo $services . “
“;
//echo $insurance . “
“;
//echo $user_address . “
“;
//echo $trans . “
;
$today = mktime(0, 0, 0, date(‘m’), date(‘d’), date(‘Y’));
$subtract = $subtract = $today – (86400 * 225);
$dt_225=date(‘Y-m-d H:i:s’, $subtract);
$db_free = new ps_DB;
$sql = “SELECT in_pk FROM insurance WHERE in_name = ‘Free'”;
$db_free->query($sql);
$db_free->next_record();
$free_pk = $db_free->f(“in_pk”);
$db_res = new ps_DB;
$sql = “SELECT * FROM provider”;
if ($services)
$sql .= “, services, services_provider_link”;
if ($insurance || $free)
$sql .= “, insurance, insurance_provider_link”;
$sql .= ” WHERE provider.rs_fk=$resources”;
if ($services)
$sql .= ” AND services.sv_pk=$services AND services_provider_link.sv_fk=$services AND services_provider_link.pr_fk=provider.pr_pk”;
if ($insurance && ($free == ‘on’))
$sql .= ” AND insurance.in_pk=$insurance AND (insurance_provider_link.in_fk=$insurance OR insurance_provider_link.in_fk=$free_pk) AND insurance_provider_link.pr_fk=provider.pr_pk”;
if (!$insurance && ($free == ‘on’))
$sql .= ” AND insurance.in_pk=$free_pk AND insurance_provider_link.in_fk=$free_pk AND insurance_provider_link.pr_fk=provider.pr_pk”;
if ($insurance && (!$free == ‘on’))
$sql .= ” AND insurance.in_pk=$insurance AND insurance_provider_link.in_fk=$insurance AND insurance_provider_link.pr_fk=provider.pr_pk”;
if ($cc_age==’0′)
$sql .= ” AND provider.`pr_cc_0-23`>0″;
if ($cc_age==’2′)
$sql .= ” AND provider.`pr_cc_2-3`>0″;
if ($cc_age==’3′)
$sql .= ” AND provider.`pr_cc_3-4`>0″;
if ($cc_age==’5′)
$sql .= ” AND provider.`pr_cc_5`>0″;
if ($trans == ‘on’)
$sql .= ” AND provider.pr_transportation=’Yes'”;
if ($age)
$sql .= ” AND provider.pr_age_min<=$age AND provider.pr_age_max>=$age”;
$sql .= ” AND pr_active=’Yes'”;
if ($g<>“No Preference” && $g<>“”) {
$sql .= ” AND ( provider.pr_gender=’$g’ OR provider.pr_gender=’Both’ )”;
}
// ONLY SHOW PROVIDERS THAT HAVE VIEWED/UPDATED PROFILE IN LAST 225 DAYS
$sql .= ” AND `pr_dt_updated` > ‘” . $dt_225 . “‘”;
// GROUP BY provider.pr_pk
$sql .= ” GROUP BY provider.pr_pk”;
// ORDER BY LAST MODIFIED DATE
$sql .= ” ORDER BY pr_dt_updated DESC”;
$dbid=$db_res->query($sql);
//if (!$dbid) {
// header(“Location: notfound.php”);
// exit();
//}
$num_rows = $db_res->num_rows();
//echo $num_rows . ” ” . $trans . ” ” . $services . ” ” . $sql . “
“;
$db_name = new ps_DB;
if ($services) {
$sql = “SELECT * FROM services WHERE sv_pk=” . $services;
$db_name->query($sql);
$db_name->next_record();
$service_name=$db_name->f(“sv_name”);
$sv_count = $db_name->f(“sv_numsearch”) + 1;
}
if ($resources) {
$sql = “SELECT * FROM resources WHERE rs_pk=” . $resources;
$db_name->query($sql);
$db_name->next_record();
$resource_name=$db_name->f(“rs_name”);
$rs_count = $db_name->f(“rs_numsearch”) + 1;
}
if ($insurance) {
$sql = “SELECT * FROM insurance WHERE in_pk=” . $insurance;
$db_name->query($sql);
$db_name->next_record();
$insurance_name=$db_name->f(“in_name”);
$in_count = $db_name->f(“in_numsearch”) + 1;
}
// Update Insurance, Resource, Service, Provider Search Counts
$db_sc = new ps_DB;
if ($insurance) {
$sql = “UPDATE insurance SET in_numsearch=$in_count WHERE in_pk=$insurance”;
$db_sc->query($sql);
}
$sql = “UPDATE resources SET rs_numsearch=$rs_count WHERE rs_pk=$resources”;
$db_sc->query($sql);
if ($services) {
$sql = “UPDATE services SET sv_numsearch=$sv_count WHERE sv_pk=$services”;
$db_sc->query($sql);
}
//echo “You searched for a ” . $resource_name . ” Resource providing ” . $service_name;
//if ($age)
// echo ” for a ” . $age . ” year old”;
//if ($insurance)
// echo ” with ” . $insurance_name . ” as the payment option.”;
//echo “
“;
?>
Comments are closed.