<?php
$db = new PDO('sqlite:climate.db');
$stmt = $db->query('
    SELECT f.id, l.name as loc, v.name as var, p.range as period, 
           f.image_climate_map_url, f.image_climate_map_url_2, f.image_time_series_url, 
           f.image_climate_stripe_url, f.image_stripe_ssp126_url, f.image_stripe_ssp245_url, 
           f.image_stripe_ssp370_url, f.image_stripe_ssp585_url 
    FROM future_climate f 
    JOIN locations l ON f.location_id = l.id 
    JOIN variables v ON f.variable_id = v.id 
    JOIN periods p ON f.period_id = p.id
');

$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
    // If any stripe URL or climate stripe URL is set, print it
    if (!empty($row['image_climate_stripe_url']) || 
        !empty($row['image_stripe_ssp126_url']) ||
        !empty($row['image_stripe_ssp245_url']) ||
        !empty($row['image_stripe_ssp370_url']) ||
        !empty($row['image_stripe_ssp585_url'])) {
        print_r($row);
    }
}
