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

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


	$q="SELECT news_id, news_title, news_message, news_image, DATE_FORMAT(news_date, '%e') AS day, DATE_FORMAT(news_date, '%b') AS month, DATE_FORMAT(news_date, '%Y') AS year, DATE_FORMAT(news_date, '%D %b, %Y') AS date FROM news  ORDER BY news_id DESC LIMIT {$pages->limit_start} ,  {$pages->limit_end}";
	$r = $db->query($q);
	for($all_news =[]; $row = $r->fetch_assoc(); $all_news[] = $row);
	}
	
?>