set_charset('utf8'); $yearOrder = 1; foreach ($saisonStart as $startYear) { $startDate = $startYear . '-08-01'; $endDate = ($startYear + 1) . '-07-31'; foreach ($bereichArray as $key => $bereich) { foreach ($teams[$key] as $teamKey => $nummer) { $berichte = $db->query('SELECT * FROM berichte WHERE Datum >= "' . $startDate . '" AND Datum <= "' . $endDate . '" AND Bereich = "' . $bereich . '" AND Nummer = "' . $nummer . '" ORDER BY Datum DESC;'); $count = $berichte->num_rows; $i = 0; $teamName = $teamNames[$key][$teamKey]; $chronikId = $chronikIds[$key][$teamKey]; if ($count > 0) { $insertTeam = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $chronikId . '" , "' . $db->real_escape_string($teamName . ' ' . $startYear . '/' . ($startYear + 1)) . '" , "" , "' . mb_strtolower($teamName, 'UTF-8') . '_' . $startYear . '" , "Y" , "' . $yearOrder . '" , "N" , NULL );'); $teamId = $db->insert_id; $updateTeam = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $teamId . '" WHERE svjf_navId = "' . $teamId . '";'); foreach ($navPoints as $navKey => $navPoint) { $insertAreas = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $teamId . '" , "' . $navPoint . '" , "" , "' . mb_strtolower($navPoint, 'UTF-8') . '" , "Y" , "' . ($navKey + 1) . '" , "' . $navSpecial[$navKey] . '" , "' . $navType[$navKey] . '" );'); $newNavStart = $db->insert_id; $updateAreas = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $newNavStart . '" WHERE svjf_navId = "' . $newNavStart . '";'); if ($navPoint = 'Spielberichte') { while ($bericht = $berichte->fetch_assoc()) { foreach ($bericht as $tmp_key => $value) { $bericht[$tmp_key] = $db->real_escape_string($value); } $insert = $db->query('INSERT INTO svjf_navi VALUES ( NULL , "' . $newNavStart . '" , "' . ($count - $i) . '. Spieltag" , "" , "spieltag_' . ($count - $i) . '" , "Y" , "' . ($i + 1) . '" , "Y" , "spielbericht" );'); $navId = $db->insert_id; $update = $db->query('UPDATE svjf_navi SET svjf_navTarget = "index.php?siteId=' . $siteId . '&navId=' . $navId . '" WHERE svjf_navId = "' . $navId . '";'); $insert = $db->query('INSERT INTO svjf_spielbericht VALUES ( "' . $navId . '" , "' . $bericht['Head'] . '" , "' . $bericht['Heim'] . '" , "' . $bericht['ErgH'] . '" , "' . $bericht['ErgG'] . '" , "' . $bericht['HalbH'] . '" , "' . $bericht['HalbG'] . '" , "' . $bericht['Gegner'] . '" , "' . $bericht['Text'] . '" , "' . $bericht['Bild'] . '" , "' . $bericht['Spieler'] . '" , "' . $bericht['Tore'] . '" , "' . $bericht['Besonderes'] . '" , "' . $bericht['Vorschau'] . '" , "' . $bericht['Datum'] . '" );'); $i++; } } else { /* TODO: svjf_content und andere Parts schreiben */ } } } } } $yearOrder++; }