prepare($sql)){ $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $param_today = $today; if($stmt->execute()){ if($stmt->rowCount() > 0){ while($row = $stmt->fetch()){ array_push($years_avail, $row['year']); } } else{ unset($stmt); } } // Free result set unset($stmt); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } if($_SERVER["REQUEST_METHOD"] == "POST"){ $year = $_POST['year']; } else { $year = $years_avail[0]; } $seminarsFuture = array('seminars' => array()); $seminarsNext = array('seminars' => array()); $seminarsPast = array('seminars' => array()); // Attempt select query execution for past seminars try{ $sql = 'SELECT id, title, person, affiliation, date, place, abstract FROM seminars WHERE date < :today AND YEAR(date) = :year ORDER BY date DESC'; if($stmt = $pdo->prepare($sql)) { $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $stmt->bindParam(":year", $param_year, PDO::PARAM_STR); $param_year = $year; if($stmt->execute()){ if($stmt->rowCount() > 0){ while($row = $stmt->fetch()){ $date = date('d.m.Y', strtotime($row['date'])); $time = date('H:i', strtotime($row['date'])); $article_data = array( 'id' => $row['id'], 'title' => $row['title'], 'person' => $row['person'], 'affiliation' => $row['affiliation'], 'date' => $date, 'time' => $time, 'place' => $row['place'], 'abstract' => $row['abstract'], 'abstractId' => 'abstract_'.$row['id'], 'can_edit' => $can_edit ); array_push($seminarsPast['seminars'], $article_data); } } else{ unset($stmt); } } // Free result set unset($stmt); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } // Attempt select query execution for next and future seminars try{ $sql = 'SELECT id, title, person, affiliation, date, place, abstract FROM seminars WHERE date >= :today ORDER BY date'; if($stmt = $pdo->prepare($sql)) { $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $param_today = $today; if($stmt->execute()){ if($stmt->rowCount() > 0){ $first = true; while($row = $stmt->fetch()){ $date = date('d.m.Y', strtotime($row['date'])); $time = date('H:i', strtotime($row['date'])); $article_data = array( 'id' => $row['id'], 'title' => $row['title'], 'person' => $row['person'], 'affiliation' => $row['affiliation'], 'date' => $date, 'time' => $time, 'place' => $row['place'], 'abstract' => $row['abstract'], 'abstractId' => 'abstract_'.$row['id'], 'can_edit' => $can_edit ); if($first){ array_push($seminarsNext['seminars'], $article_data); $first = false; } else { array_push($seminarsFuture['seminars'], $article_data); } } } else{ unset($stmt); } } // Free result set unset($stmt); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } #seminar template $seminar = $twig->load('seminar_en.html'); ?>