<?php 
include("public.php");
if(isset($_GET['page'])){
   $page=$_GET['page'];
  } else {
      $page=0; // page is for url number like page=1,page=2
  }
  $rowsPerPage=5; // This is how many user showing in one page
  $offset=($page-1)* $rowsPerPage; //Balancing the number of user shown
  $updatesarray=$Mat->Friends_List($profile_uid, $page, $offset, $rowsPerPage) ;
  if($updatesarray) {
      $last_letter = "";
      foreach($updatesarray as $data) {
          $list_username=$data['username'];
          $friend_uid=$data['uid'];
		  $check_verif=$data['verified'];
		  // user profile image for follower list
          $userface=$Mat->User_Lister($friend_uid,$base_url);
		  // user full name for follower list
          $userfullname = $Mat->UserFullName($list_username);
          $letter = mb_strtoupper(mb_substr($userfullname,0,1 , "UTF-8"), "UTF-8");
          if($letter != $last_letter) {
			 // alphabetically the knee
             echo '<div class="list-alphabet">'.$letter.'</div>'; 
             $last_letter = $letter;
          }
?>
 <div class="follower md-ripple">
   <div class="follower-img"><img src="<?php echo $userface;?>" border="0"></div>
     <a href="<?php echo $base_url.$list_username;?>"><div class="follower-name"><?php echo htmlspecialchars($userfullname); ?><?php if($check_verif == 1){ echo '<img src="'.$base_url.'mat_icons/verified.png" width="23px" height="23px">';}?></div></a>
<?php   
$profile_uid=$friend_uid; 
include('follow_unfollow_follower_list.php'); 
?>
</div>
<?php
}
} else {
    echo '<div class="no-added-friend">No person will be shown!</div>';
}
//Next Previous Buttons
if($friend_count > $rowsPerPage){
	// If the user follower count greater then trowsperpage then show the next and previous button
   $maxPage = ceil($friend_count/$rowsPerPage);
   $self = $_SERVER['PHP_SELF'];
   $nav = '';
   $prev='';
   $next='';
   if($page > 1){
       $pagee = $page - 1; // If URl number is bigger then 1
       $path=$base_url.'following/'.$username.'/'.$pagee; // button URL for previous users
       $prev = "<span id=\"prev\" class='nbutton color'> <a href='$path' class='next'>&lsaquo;&lsaquo; Prev</a></span> &bull; ";
    }
    if($page < $maxPage){
		// If the maximum page number bigger then tpage then show the next button
       if($page){
          $pagee= $page + 1;	
        }else{
             $pagee= $page + 2;	
            }
            $path=$base_url.'following/'.$username.'/'.$pagee; // Button URL for next users
            $next = "<span id=\"next\" class='nbutton color'> <a href='$path' class='next'>Next &rsaquo;&rsaquo;</a></span> ";	
     } 
?>
<div style="
  float:left;
  width: 100%;
  text-align: center;
  background-color:#ffffff;
  padding-bottom:10px;
  padding-top:10px;
  color:#009688;
  font-weight: 600;
  font-size: 16px;
  font-family: Helvatica,Arial, 'lucida grande',tahoma,verdana,arial,sans-serif;
  -webkit-border-bottom-right-radius: 3px;
  -webkit-border-bottom-left-radius: 3px;
  -moz-border-radius-bottomright: 3px;
  -moz-border-radius-bottomleft: 3px;
  border-bottom-right-radius: 3px;
  border-bottom-left-radius: 3px;">
<?php echo $prev; ?>
<?php echo $next; ?>
</div>
<?php 
} 
?>

