예제 #1
0
 function printLeveesByZip($zip)
 {
     echo "<ol>";
     $query = "SELECT * FROM leveerisk";
     $result = mysql_query($query);
     while ($levee = mysql_fetch_array($result)) {
         $z = new zipcode_class();
         $miles = $z->get_distance($zip, $levee[zip]);
         //if($miles === false) echo '<p>Error: '.$z->last_error.'</p>';
         if ($miles < 100) {
             printLeveeDetails($levee[id]);
         }
     }
     echo "</ol>";
 }
<?php

include_once "inc/common_functions.php";
include_once "inc/page.inc.php";
require_once 'inc/db.inc.php';
require_once 'zipcode.class.php';
session_start();
// accesses common functions
$func = new COMMONFUNC();
// database access
$db = new DB();
// zip code search
$z = new zipcode_class();
if ($_SESSION['mode'] != "college" or $_SESSION['FRONTEND_USER'] == "") {
    header("Location:index.php");
}
$coachId = $_SESSION['College_Coach_id'];
$needId = NULL;
$fldCollegeId = NULL;
$fldSport = NULL;
$fldGradClass = NULL;
$fldMinHeight = NULL;
$fldMaxHeight = NULL;
$fldMinWeight = NULL;
$fldMaxWeight = NULL;
$fldPosition = NULL;
$fldMinBenchPress = NULL;
$fldMinSquatMax = NULL;
$fldMax40YardDash = NULL;
$fldMaxShuttleRun = NULL;
$fldMinVertical = NULL;
예제 #3
0
<?php 
/*  
   DEMO for using the zipcode PHP class. By: Micah Carrick 
   Questions?  Comments?  Suggestions?  email@micahcarrick.com
*/
require_once 'zipcode.class.php';
// zip code class
// Open up a connection to the database.  The sql required to create the MySQL
// tables and populate them with the data is in the /sql subfolder.  You can
// upload those sql files using phpMyAdmin or a MySQL prompt.  You will have to
// modify the below information to your database information.
mysql_connect('localhost:3306', 'trailblazer', 'trailblazer') or die(mysql_error());
mysql_select_db('zip_codes') or die(mysql_error());
// Below is an example of how to calculate the distance between two zip codes.
echo '<h3>A sample calculating the distance between 2 zip codes: 93001 and 60618</h3>';
$z = new zipcode_class();
$miles = $z->get_distance(97214, 98501);
if ($miles === false) {
    echo 'Error: ' . $z->last_error;
} else {
    echo "Zip code <b>97214</b> is <b>{$miles}</b> miles away from <b>98501</b>.<br />";
}
// Below is an example of how to return an array with all the zip codes withing
// a range of a given zip code along with how far away they are.  The array's
// keys are assigned to the zip code and their value is the distance from the
// given zip code.
echo '<h3>A sample getting all the zip codes withing a range: 2 miles from 97214</h3>';
$zips = $z->get_zips_in_range('97214', 2, _ZIPS_SORT_BY_DISTANCE_ASC, true);
if ($zips === false) {
    echo 'Error: ' . $z->last_error;
} else {
 public static function getSchoolsInDistance($zip, $distance)
 {
     if (empty($zip)) {
         return '';
     }
     if ($distance === 'any') {
         return " AND `fldSchool` != ''";
     }
     if (empty($distance)) {
         $query = 'SELECT `fldId` FROM ' . TBL_HS_AAU_TEAM . " WHERE `fldZipcode`='" . mysql_real_escape_string($zip) . "' AND `fldStatus`='ACTIVE'";
     } else {
         $z = new zipcode_class();
         $zips = $z->get_zips_in_range(mysql_real_escape_string($zip), intval($distance), _ZIPS_SORT_BY_DISTANCE_ASC, true);
         $fldzip_code = implode(',', $zips);
         $query = 'SELECT `fldId` FROM ' . TBL_HS_AAU_TEAM . ' WHERE `fldZipcode` IN (' . $fldzip_code . ") AND `fldStatus`='ACTIVE'";
     }
     $db = new DB();
     if (!$db->query($query)) {
         die(mysql_error());
     }
     $schools = array(0);
     while ($db->next_record()) {
         $schools[] = $db->f('fldId');
     }
     return ' AND `fldSchool` IN (' . implode(',', $schools) . ')';
 }
<?php

session_start();
include_once "inc/common_functions.php";
//for common function
include_once "inc/page.inc.php";
$func = new COMMONFUNC();
$db = new DB();
require_once 'zipcode.class.php';
$z = new zipcode_class();
if ($_SESSION['mode'] == "" or $_SESSION['FRONTEND_USER'] == "") {
    header("Location:index.php");
}
$flag = 0;
$flag_zip = 0;
$page = new Page();
if ($_POST['isSubmit'] == 'save') {
    $select_college_zipcode = $func->selectTableOrder(TBL_COLLEGE, "fldId,fldZipCode", "fldId", "where fldId='" . $_POST['fldCollegename'] . "'");
    $zips = $z->get_zips_in_range($select_college_zipcode['0']['fldZipCode'], $_POST['fldDistance'], _ZIPS_SORT_BY_DISTANCE_ASC, true);
    $condition = "";
    if ($_POST['fldCollegename'] and $_POST['fldDistance'] != 'select') {
        $fldzip_code = implode(',', $zips);
        if ($fldzip_code != "") {
            $condition .= "fldZipCode in (" . $fldzip_code . ") and ";
        } else {
            $flag_zip++;
        }
    }
    if ($_POST['fldDistance'] == 'any') {
        $condition .= "fldZipCode != '' and ";
    }