<?php  

  session_start();
   error_reporting(0);
		include("../db.php");
		include("../all_query.php");
		

 if(isset($_SESSION['loan_crm_username']) && isset($_SESSION['loan_crm_password']))
{
	
	$_SESSION['timestamp'] = time();  
	
	
	
		   $current_account_holder_id = $_REQUEST['current_account_holder_id'];
		  $type = $_REQUEST['type'];
	
	      $all_row_ids = $_SESSION['all_row_ids'];
		  
		 
		   $index = array_search($current_account_holder_id, $all_row_ids);
		  
	       if($index != false && $index > 0 ) {  $prev = $all_row_ids[$index-1]; }
		   if($index != false && $index < count($all_row_ids)-1) { $next = $all_row_ids[$index+1]; }
	
	  
	   if($index == 0)
	   {
		 echo  $all_row_ids[1];
	   }
	   
	   else
		   
		   {
	  
	   if($type == 'next')
	   {
		  echo $next;
	   }
	   
	    if($type == 'prev')
	   {
		   echo $prev;
	   }
	   
	   
		   }
	   
	   
	
}


?>