Location: PHPKode > scripts > GG-Tracker GPS and GSM Tracking > gg-tracker-gps-and-gsm-tracking/calc_stats.php
<?php

//Include some math
include ("math_functions.php");

//Calculate distance from home
$disthome = great_circle_distance ($homepos[0], $homepos[1], $latitude, $longitude);

//Calculate number of GSM antenna's in database
$query = 'SELECT CELL_ID, LAC, MCC, MNC, COUNT(*) FROM GPS GROUP BY cell_id ';
$result = mysqli_query($link, $query);

$gsm_antenna = array(0,0);

while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	$n_ant = $line['COUNT(*)'];
	$gsm_antenna[1]++;
	if ($n_ant > $ant_threshold) $gsm_antenna[0]++;
}

//Calculate maximum speed today and ever
$query = 'SELECT MAX(SPEED_KNOTS) FROM GPS';
$result = mysqli_query($link, $query);

while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	$maxspeed[0] = round($line['MAX(SPEED_KNOTS)'] * 1.852,0);
}

$query = 'SELECT MAX(SPEED_KNOTS) FROM GPS WHERE TIME_RECEIVED >= CURDATE()';
$result = mysqli_query($link, $query);

while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	$maxspeed[1] = round($line['MAX(SPEED_KNOTS)'] * 1.852,0);
}

?>
Return current item: GG-Tracker GPS and GSM Tracking