From 1d928efb0ad20169d145233570d75664827684a0 Mon Sep 17 00:00:00 2001 From: Tim Weber Date: Tue, 16 Jun 2020 01:25:51 +0200 Subject: [PATCH] check year when fetching current schedule --- admin/header.php | 6 +++--- index.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/header.php b/admin/header.php index 63dd5a0..4f82943 100644 --- a/admin/header.php +++ b/admin/header.php @@ -12,10 +12,10 @@ if(!$db) exit("Database connection error: ".mysqli_connect_error()); // Datenbankabfrage aktueller Wochenplan - $sql = 'SELECT * FROM schedules WHERE calendar_week = ?'; + $sql = 'SELECT * FROM schedules WHERE calendar_week = ? AND year = ?'; $sql_query = mysqli_prepare($db, $sql); - if (!$sql_query) die('ERROR: could not prepare sql: '.$sql); - mysqli_stmt_bind_param($sql_query, 'i', date('W')); + if (!$sql_query) die('ERROR: Failed to prepare SQL.'); + mysqli_stmt_bind_param($sql_query, 'is', date('W'), date('Y')); mysqli_stmt_execute($sql_query); $current_schedule = mysqli_fetch_assoc(mysqli_stmt_get_result($sql_query)); mysqli_stmt_close($sql_query); diff --git a/index.php b/index.php index 69e1d1c..8242496 100644 --- a/index.php +++ b/index.php @@ -15,10 +15,10 @@ if(!$db) exit('Database connection error: '.mysqli_connect_error()); // Datenbankabfrage aktueller Wochenplan - $sql = 'SELECT * FROM schedules WHERE calendar_week = ?'; + $sql = 'SELECT * FROM schedules WHERE calendar_week = ? AND year = ?'; $sql_query = mysqli_prepare($db, $sql); if (!$sql_query) die('ERROR: Failed to prepare SQL.'); - mysqli_stmt_bind_param($sql_query, 'i', date('W')); + mysqli_stmt_bind_param($sql_query, 'is', date('W'), date('Y')); mysqli_stmt_execute($sql_query); $current_schedule = mysqli_fetch_assoc(mysqli_stmt_get_result($sql_query)); mysqli_stmt_close($sql_query);