$dbhost = '192.168.1.10';
$dbuser = 'slowtwitch';
$dbpass = 'k9volqlAcpq';
$dbname = 'training';
$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die ('Error connecting to mysql server: ' . mysql_error());
mysql_select_db($dbname)
or die ('Error selecting ' . $dbname . ': ' . mysql_error());
if (isset($_GET["action"]) && isset($_GET["id"])) {
$action = $_GET["action"];
$id = $_GET["id"];
if ($action == "delete" && $id != "") {
$queryCopy = "insert into ugomo_workout_challenge_history (challenge_id, created_by, challenge_type, challenge_name, start_date, end_date, challenge_value, unit, meassure, sport, notes, min_time, min_distance, min_distance_unit) SELECT challenge_id, created_by, challenge_type, challenge_name, start_date, end_date, challenge_value, unit, meassure, sport, notes, min_time, min_distance, min_distance_unit FROM ugomo_workout_challenge WHERE ugomo_workout_challenge.challenge_id = " . $id;
$resultCopy = mysql_query($queryCopy);
$queryDelete = "delete from ugomo_workout_challenge where challenge_id = " . $id;
$resultDelete = mysql_query($queryDelete);
}
header("Location: /tladmin");
}
?>
ST - Training Log Admin
// Users with at least one logged workout
$query = "select user_id, count(*) from ugomo_workout group by user_id order by user_id";
$result = mysql_query($query);
$usersWithOneWorkout = mysql_num_rows($result);
// Total workouts logged
$query = "select count(*) AS total from ugomo_workout";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$totalWorkoutsLogged = $row["total"];
// Total workouts logged in the last 7 days
$yesterday = date("Y-m-d", strtotime("now") - 86400);
$oneWeekAgo = date("Y-m-d", strtotime("now") - (86400 * 7));
$query = "select count(*) AS total from ugomo_workout where workout_date >= '" . $oneWeekAgo . "' AND workout_date <= '" . $yesterday . "'";
// echo $query . '
';
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$workoutsLoggedLastWeek = $row["total"];
?>
Challenge Stats
Users with at least one workout logged: | =number_format($usersWithOneWorkout)?> |
Total workouts logged: | =number_format($totalWorkoutsLogged)?> |
Workouts logged in previous 7 days: | =number_format($workoutsLoggedLastWeek)?> |
Challenge Admin
$query = "select challenge_id, created_by, challenge_name, start_date, end_date from ugomo_workout_challenge";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
echo '';
echo '' . $row["challenge_name"] . ' | ';
echo '' . $row["start_date"] . ' | ';
echo '' . $row["end_date"] . ' | ';
echo '' . $row["created_by"] . ' | ';
echo 'Delete | ';
echo '
' . "\n";
}
?>