";
echo "
";
echo "
Top Species
";
echo "
";
echo "
";
echo "";
echo "Common Name | ";
echo "Total Detections | ";
echo "Last Heard | "; // Modified column name
echo "Image | ";
echo "
";
if (isset($top_species['species']) && is_array($top_species['species'])) {
foreach ($top_species['species'] as $species) {
echo "";
echo "" . $species['commonName'] . " | ";
echo "" . $species['detections']['total'] . " | ";
// Assuming 'latestDetectionAt' is a part of the species array and formatted as ISO8601 datetime
if (isset($species['latestDetectionAt'])) {
$latest_detection_time = strtotime($species['latestDetectionAt']);
$latest_detection_date = date('m/d', $latest_detection_time);
if ($today == date('Y-m-d', $latest_detection_time)) {
$latest_detection_date = 'Today';
} elseif ($latest_detection_time >= strtotime('-5 days')) {
$latest_detection_date = date('l', $latest_detection_time);
}
echo "" . date('g:i a, ', $latest_detection_time) . $latest_detection_date . " | "; // Modified column value
} else {
echo "No detection time available | ";
}
echo " | ";
echo "
";
}
}
echo "
";
echo "
"; // Close table-container
echo "
"; // Close top-species
// Display latest detections
echo "
";
echo "
";
echo "
Latest Detections
";
echo "
";
echo "
";
echo "";
echo "Species | ";
echo "Detection Time | ";
echo "Confidence | ";
echo "Listen! | "; // New column for play button
echo "
";
if (isset($detections['detections']) && is_array($detections['detections'])) {
foreach ($detections['detections'] as $detection) {
echo "";
echo "" . $detection['species']['commonName'] . " | ";
echo "" . date('g:i a, m/d', strtotime($detection['timestamp'])) . " | ";
echo "" . $detection['confidence'] . " | ";
echo "";
if (isset($detection['soundscape']['url'])) {
echo "Play";
} else {
echo "fixThis";
}
echo " | ";
echo "
";
}
}
echo "
";
echo "
"; // Close table-container
echo "
"; // Close latest-detections
echo "";
echo "
"; // Close table-container
echo "
"; // Close data-section
echo ""; // Close weather-stats-container
?>
```