['default' => 1]]); } else{ $archive_page = 1; } $conferences_per_page = 10; require_once ROOT_PATH.'/php/config_db.php'; try{ $sql = 'SELECT COUNT(*) as total FROM conferences'; $result = $pdo->query($sql); if($result->rowCount() > 0){ while($row = $result->fetch()){ $max_page = ceil($row['total']/$conferences_per_page); } // Free result set unset($result); } else{ unset($pdo); http_response_code(404); include('/pl/404.html'); die(); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } $pages = array('pages' => array( 'first' => max(1, $archive_page-2), 'last' => min($max_page, $archive_page+2), 'current' => $archive_page, 'base_link' => 'conferences.html?page=' )); $conferencesUpcoming = array('conferences' => array()); $conferencesCurrent = array('conferences' => array()); $conferencesPrevious = array('conferences' => array()); $today = date('Y-m-d'); // Attempt select query execution for previous conferences try{ $sql = 'SELECT id, title, venue, date_from, date_to, add_info_en, logo, website FROM conferences WHERE date_from < :today AND date_to < :today ORDER BY date_from DESC LIMIT :limit OFFSET :offset'; if($stmt = $pdo->prepare($sql)) { $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $stmt->bindParam(":limit", $param_limit, PDO::PARAM_INT); $stmt->bindParam(":offset", $param_offset, PDO::PARAM_INT); $param_today = $today; $param_limit = $conferences_per_page; $param_offset = ($archive_page-1)*$conferences_per_page; if($stmt->execute()){ if($stmt->rowCount() > 0){ while($row = $stmt->fetch()){ if(!empty($row['logo'])){ $logo = '/files/conferences/'.$row['logo']; } else { $logo = ''; } $article_data = array( 'id' => $row['id'], 'title' => $row['title'], 'venue' => $row['venue'], 'dateStart' => date('d.m.Y', strtotime($row['date_from'])), 'dateEnd' => date('d.m.Y', strtotime($row['date_to'])), 'addInfo' => $row['add_info_en'], 'logo' => $logo, 'website' => $row['website'], 'can_edit' => $can_edit ); array_push($conferencesPrevious['conferences'], $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 current conferences try{ $sql = 'SELECT id, title, venue, date_from, date_to, add_info_en, logo, website FROM conferences WHERE date_from <= :today AND date_to >= :today ORDER BY date_from DESC'; if($stmt = $pdo->prepare($sql)) { $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $param_today = $today; if($stmt->execute()){ if($stmt->rowCount() > 0){ while($row = $stmt->fetch()){ if(!empty($row['logo'])){ $logo = '/files/conferences/'.$row['logo']; } else { $logo = ''; } $article_data = array( 'id' => $row['id'], 'title' => $row['title'], 'venue' => $row['venue'], 'dateStart' => date('d.m.Y', strtotime($row['date_from'])), 'dateEnd' => date('d.m.Y', strtotime($row['date_to'])), 'addInfo' => $row['add_info_en'], 'logo' => $logo, 'website' => $row['website'], 'can_edit' => $can_edit ); array_push($conferencesCurrent['conferences'], $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 future conferences try{ $sql = 'SELECT id, title, venue, date_from, date_to, add_info_en, logo, website FROM conferences WHERE date_from > :today AND date_to > :today ORDER BY date_from DESC'; if($stmt = $pdo->prepare($sql)) { $stmt->bindParam(":today", $param_today, PDO::PARAM_STR); $param_today = $today; if($stmt->execute()){ if($stmt->rowCount() > 0){ while($row = $stmt->fetch()){ if(!empty($row['logo'])){ $logo = '/files/conferences/'.$row['logo']; } else { $logo = ''; } $article_data = array( 'id' => $row['id'], 'title' => $row['title'], 'venue' => $row['venue'], 'dateStart' => date('d.m.Y', strtotime($row['date_from'])), 'dateEnd' => date('d.m.Y', strtotime($row['date_to'])), 'addInfo' => $row['add_info_en'], 'logo' => $logo, 'website' => $row['website'], 'can_edit' => $can_edit ); array_push($conferencesUpcoming['conferences'], $article_data); } } else{ unset($stmt); } } // Free result set unset($stmt); } } catch(PDOException $e){ die('ERROR: Could not able to execute $sql. ' . $e->getMessage()); } #conference template $conference = $twig->load('conference_pl.html'); $pagination = $twig->load('pagination_pl.html'); ?>