<?php	
	$statement = $db_con->prepare("SELECT count(nw_id) FROM newspost WHERE delete_status = 0");
	$sum_rows = 0; if(!empty($statement)) { $statement->execute(); 	$sum_rows = $statement->fetchColumn(); }
	$rows = $sum_rows; $page_rows = 12; $last = ceil($rows/$page_rows);
	if($last < 1){ 	$last = 1; } $pagenum = 1;
	if(isset($_GET['pg'])){	 $pagenum = preg_replace('#[^0-9]#', '', $_GET['pg']);	}
	if ($pagenum < 1) { $pagenum = 1; } elseif($pagenum > $last){ $pagenum = $last; }
	$limit = ' LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
	
	
	
	$nquery = gtAll("newspost"," nw_id <> '' ","nwdate DESC $limit");
	$current = ($pagenum * $page_rows); $start_limit = (($pagenum - 1) * $page_rows) + 1;
	if($pagenum == $last){	$current_limit = $sum_rows; } else{	$current_limit = $current; }
	$nv = "?";
	$paginationCtrls = $paginationCtrlsLeft = $paginationCtrlsRight = '';
	if ($pagenum > 1) { $previous = $pagenum - 1;  $paginationCtrlsLeft .= '<a href="'.$_SERVER['PHP_SELF'].$nv.'pg='.$previous.'" title="Previous"><i class="fa fa-angle-left"></i></a>'; }
	else{ $paginationCtrlsLeft .= '<a href="javascript:void(0);" style="cursor: not-allowed;" title="Previous"><i class="fa fa-angle-left"></i></a>'; }
	if ($pagenum != $last) {$next = $pagenum + 1; $paginationCtrlsRight .= '<a href="'.$_SERVER['PHP_SELF'].$nv.'pg='.$next.'" title="Next"><i class="fa fa fa-angle-right"></i></a>';}
	else { $paginationCtrlsRight .= '<a href="javascript:void(0);" style="cursor: not-allowed;" title="Next"><i class="fa fa-angle-right"></i></a>'; }
	$paginationCtrls .= $paginationCtrlsLeft.'<span>Showing '.$start_limit .'-'. $current_limit.' of '.$sum_rows.'</span>'.$paginationCtrlsRight;
?>