In de Where clausule van mijn query staat het seizoen gedefinieerd. Om niet elk jaar alle queries aan te passen zou ik dit eenmaling in een soort van admin page willen steken.
Hoe begin ik hieraan?


"SELECT matches.matchid, matches.matchdate, matches.matchtime AS uur, teams.teamname AS thuisploeg, teams1.teamname AS bezoekers, matches.homescore, matches.awayscore
FROM teams AS teams1
INNER JOIN (
teams
INNER JOIN matches ON teams.teamid = matches.teamhome
) ON teams1.teamid = matches.teamaway
WHERE  season = '2014_2015'

ORDER BY matches.matchdate";
Een voetbal seizoen loopt van september tot en met juni?

<?php

function getSeason()
{
$currentYear = date('Y');
$currentMonth = date('n');
if($currentMonth <= 6)
$currentYear--;
$nextYear = $currentYear + 1;

return $currentYear . '_' . $nextYear;
}
?>
Je stopt active_season ergens in een admin of instellingen tabel en haalt die eerst op in bijv veld $active_season.

En dan verander je de select in:

"SELECT matches.matchid, matches.matchdate, matches.matchtime AS uur, teams.teamname AS thuisploeg, teams1.teamname AS bezoekers, matches.homescore, matches.awayscore
FROM teams AS teams1
INNER JOIN (
teams
INNER JOIN matches ON teams.teamid = matches.teamhome
) ON teams1.teamid = matches.teamaway
WHERE  season = '" . $active_season . "'

ORDER BY matches.matchdate";
Thx guys, ik ga dit eens uitproberen.

Reageren