예제 #1
0
    }
    if (!validate_heartrate($max_hr[$i])) {
        $error[$i] = true;
    }
    if ($i == 1) {
        if (!validate_rpms($avg_rpms)) {
            $error[$i] = true;
        }
    }
    if (!validate_calories($calsburned[$i])) {
        $error[$i] = true;
    }
}
// Calculate the correct pace
if (!empty($distance[0]) && !empty($duration[0])) {
    $pace[0] = swimpace($second[0], $distance[0]);
}
if (!empty($distance[1]) && !empty($duration[1])) {
    $pace[1] = bikepace($seconds[1], $distance[1]);
}
if (!empty($distance[2]) && !empty($duration[2])) {
    $pace[2] = runpace($seconds[2], $distance[2]);
}
// If we don't have any errors then go ahead and insert the new record(s) into the table.
for ($i = 0; $i < 3; $i++) {
    switch ($i) {
        case 0:
            if (!$error[0]) {
                if ($updatingswim) {
                    $query = "UPDATE flmain" . " SET plan_type='" . $plan_type . "', sbr_type='" . $activity[$i] . "', duration='" . $duration[$i] . "', seconds=" . $seconds[$i] . ", distance='" . $distance[$i] . "', pace='" . $pace[$i] . "', min_hr=" . $min_hr[$i] . ", avg_hr=" . $avg_hr[$i] . ", max_hr=" . $max_hr[$i] . ", notes='" . $notes[$i] . "', user_id={$userID}, cals_burned=" . $calsburned[$i] . " WHERE workout_date='" . $workout_date[$i] . "' AND time_of_day='" . $workout_time[$i] . "'";
                } else {
예제 #2
0
 // formate the duration for now in hh:mm:ss
 $duration = format_time(intval($row[SECONDS]));
 // Convert all the strings into the appropriate int or float value.
 $seconds = intval($row[SECONDS]);
 $distance = floatval($row[DISTANCE]);
 $min_hr = intval($row[MIN_HR]);
 $avg_hr = intval($row[AVG_HR]);
 $max_hr = intval($row[MAX_HR]);
 // Get the string values from the array.
 $workout_date = $row[WORKOUT_DATE];
 $sbr_type = $row[SBR_TYPE];
 $notes = $row[NOTES];
 // Calculate the pace inforamtion.
 switch ($row[SBR_TYPE]) {
     case "s":
         $pace = swimpace($seconds, $distance);
         break;
     case "b":
         $pace = bikepace($seconds, $distance);
         break;
     case "r":
         $pace = runpace($seconds, $distance);
         break;
     default:
         $pace = 0;
         break;
 }
 $query = "INSERT INTO flmain (plan_type, sbr_type, duration, seconds, distance, pace, workout_date, time_of_day, min_hr, avg_hr, max_hr, notes, user_id, cals_burned) VALUES ('{$plan_type}', '{$sbr_type}', '{$duration}', {$seconds}, {$distance}, {$pace}, '{$workout_date}', '00:00:00', {$min_hr}, {$avg_hr}, {$max_hr}, '{$notes}', {$userID}, 0)";
 var_dump($query);
 // Run the query
 $result = @mysql_query($query, $connection);
예제 #3
0
<?php

require 'fitlogfunc.php';
// Get time, distance and activity
$strtime = strval($_GET['time']);
$distance = floatval($_GET['distance']);
$activity = strval($_GET['activity']);
// convert the parsed time into seconds and put that into the $time variable
$time = convert_time_seconds($strtime);
switch ($activity) {
    case "swim":
        $pace = swimpace($time, $distance);
        break;
    case "bike":
        $pace = bikepace($time, $distance);
        break;
    case "run":
        $pace = runpace($time, $distance);
        break;
    default:
        $pace = 0;
        break;
}
echo $pace;