query( 'SELECT b.slug AS brand_slug, m.slug AS model_slug, m.updated_at FROM car_models m JOIN brands b ON b.id = m.brand_id' )->fetchAll(); $brands = $db->query('SELECT slug, updated_at FROM brands')->fetchAll(); $urls = [ ['loc' => '/', 'priority' => '1.0'], ['loc' => '/fahrzeuge', 'priority' => '0.9'], ['loc' => '/kontakt', 'priority' => '0.5'], ]; foreach ($brands as $brand) { $urls[] = ['loc' => "/fahrzeuge/{$brand['slug']}", 'priority' => '0.8', 'lastmod' => $brand['updated_at']]; } foreach ($models as $model) { $urls[] = [ 'loc' => "/fahrzeuge/{$model['brand_slug']}/{$model['model_slug']}", 'priority' => '0.7', 'lastmod' => $model['updated_at'], ]; } header('Content-Type: application/xml; charset=utf-8'); echo '' . "\n"; echo '' . "\n"; foreach ($urls as $url) { echo " \n"; echo ' ' . htmlspecialchars($siteUrl . $url['loc']) . "\n"; if (!empty($url['lastmod'])) { echo ' ' . date('Y-m-d', strtotime($url['lastmod'])) . "\n"; } echo ' ' . $url['priority'] . "\n"; echo " \n"; } echo '';