exec("SET CHARACTER SET utf8"); $req = $bdd->prepare('SELECT wplg_posts.ID, post_date AS date, wplg_postmeta.meta_id AS team_meta_id, wplg_postmeta.meta_value AS team_id, abbrev.meta_value AS team_abbreviation FROM wplg_posts INNER JOIN wplg_postmeta ON ID = wplg_postmeta.post_id INNER JOIN (SELECT post_id, meta_value FROM wplg_postmeta WHERE meta_key = "sp_abbreviation") AS abbrev ON abbrev.post_id = wplg_postmeta.meta_value WHERE post_type = "sp_event" AND DATE_FORMAT(post_date,"%Y-%m-%d") = DATE_FORMAT(CURRENT_DATE(),"%Y-%m-%d") # CURRENT_DATE() AND meta_key IN ("sp_team") ORDER BY post_date, meta_id' ); $req->execute(); // tableaux des résultats $raw_data_matchs = $req->fetchAll(PDO::FETCH_ASSOC); $date = date("Y/m/d"); $h1_title = ($raw_data_matchs) ? "Matchs à l’horaire - " . $date : "Pas de matchs à l’horaire aujourd’hui - " . $date; if (!$raw_data_matchs) $match_informations = []; // Fermeture de la requête et de la base de données $req->closeCursor(); $bdd = null; foreach ($raw_data_matchs as $i => $a) { // i est un index; a est un array // match_informations sont des valeurs à afficher $match_informations[$i]["ID"] = $a["ID"]; $match_informations[$i]["date"] = date_format(date_create($a["date"]), "md"); $match_informations[$i]["time"] = date_format(date_create($a["date"]), "Hi"); $is_first_index = ($i == 0) ? 1 : false; $p_ID = ($is_first_index) ?: $match_informations[$i - 1]["ID"]; if ($a["ID"] == $p_ID) $match_informations[$i]["away"] = $raw_data_matchs[$i - 1]["team_abbreviation"]; $match_informations[$i]["home"] = $a["team_abbreviation"]; } foreach ($match_informations as $key => $value) { if ($key - 1 < 0) continue; if ($value["ID"] == $match_informations[$key - 1]["ID"]) unset($match_informations[$key - 1]); } } catch(Exception $e) { die('Erreur : ' . $e->getMessage()); } ?>
|
Visiteur
=$mi["away"];?>
|
Date
=$mi["date"];?>
|
Heure
=$mi["time"];?>
|
|
Domicile
=$mi["home"];?>
|