<?php
	require_once("{$_SERVER['DOCUMENT_ROOT']}/private/includes/initialize.php");
	$mysqli->select_db($secondary_db);
	require_once("{$_SERVER['DOCUMENT_ROOT']}/private/paginator.class.php");
	$event_category = '';

	$q="SELECT COUNT(event_id) AS event_count FROM event";
	$r = $db->query($q);
	for($event_count = 0; $row = $r->fetch_assoc(); $event_count = $row['event_count']);
	$r->free();
	if($event_count > 0){
	$pages = new Paginator($event_count,3,array(6,15,20,25,30,'All'));


	$q="SELECT event_id, event_title, description AS event_message, event_image, location, DATE_FORMAT(start_date, '%e') AS day, DATE_FORMAT(start_date, '%b') AS month, DATE_FORMAT(start_date, '%Y') AS year, DATE_FORMAT(start_date, '%D %b, %Y') AS date FROM event ORDER BY event_id DESC LIMIT {$pages->limit_start} ,  {$pages->limit_end}";
	$r = $db->query($q);
	for($all_events =[]; $row = $r->fetch_assoc(); $all_events[] = $row);
	}
?>